Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. An nx n matrix is called a positive Markov matrix if each element is positive

ID: 3168256 • Letter: 1

Question

1. An nx n matrix is called a positive Markov matrix if each element is positive and the sum of the elements in each column is 1. Define the following method to check whether a matrix of double values is a positive Markov matrix public static boolean isMarkovMatrix (double ] m) Write a test program that prompts the user to enter a 3 x 3 matrix of double values and reports whether it is a positive Markov matrix. Sample run #1: Enter a 3 by 3 matrix, row by row 0.15 0.875 0.375 0.55 0.005 0.225 0.30 0.12 0.4 This is a positive Markov matrix Sample run #2: Enter a 3 by 3 matrix, row by row: 0.95-0.875 0.375 0.65 0.005 0.225 0.30 0.22-0.4 This is not a positive Markov matrix

Explanation / Answer

Here I am writing programm in matlab

%%% Matlab code %%%

%%%% Matlab code %%%%%

clc;
clear all;
close all;
format short
%%% restoredefaultpath %%%
disp('Enter the matrix row by row');
for n=1:3
    for k=1:3
        A(n,k)=input(' ');
    end
end
disp('Your Entrred matrix: ');
A
temp=0;
for n=1:3;
    s=0;
    for k=1:3;
       if A(k,n) < 0
           temp=1;
           break;
       else
           s=s+A(k,n);
       end
    end
        if (temp ==1)
            break
        else
            if ( s ~=1)
                temp=1;
            end
        end
  
end

if (temp==1)
    disp('This is not positive markov matrix');
else
    disp('This is positive markov matrix');
end

OUTPUT:

Enter the matrix row by row
0.15
0.875
0.375
0.55
0.005
0.225
0.30
0.12
0.4
Your Entrred matrix:

A =

    0.1500    0.8750    0.3750
    0.5500    0.0050    0.2250
    0.3000    0.1200    0.4000

This is positive markov matrix

Enter the matrix row by row
0.95
-0.875
0.375
0.65
0.005
0.225
0.30
0.22
-0.4
Your Entrred matrix:

A =

    0.9500   -0.8750    0.3750
    0.6500    0.0050    0.2250
    0.3000    0.2200   -0.4000

This is not positive markov matrix