function nmaTestMarkov() p1=[1 0 0 0 0; 0 .2 .8 0 0; 0 .7 .3 0 0; .1 0 .1 .4 .4; 0 .1 .3 .2 .4]; testIt(p1); fprintf('\n\n'); p1=[ .1 .3 0 0 .6; 0 .2 .7 0 .1; 0 .7 .3 0 0; .1 0 .1 .4 .4; 0 .1 .3 .2 .4]; testIt(p1); fprintf('\n\n'); p1=[ .5 .5 0 0 0 0; 0 0 1 0 0 0; 1/3 0 0 1/3 1/3 0; 0 0 0 1/2 1/2 0; 0 0 0 0 0 1; 0 0 0 0 1 0]; testIt(p1); p1=[ 1 0 0 0 0 0; 0 1 0 0 0 0; 0 0 1 0 0 0; 0 0 0 0 1/2 1/2; 1/4 1/4 0 0 0 .5; 1/4 0 1/4 0 1/2 0]; %closed {1},{2},{3} testIt(p1); p1=[ 1 0 0 0 0 0 0 0 0; 0 1 0 0 0 0 0 0 0; 2/9 1/9 0 1/12 1/9 5/36 5/36 1/9 1/12; 5/36 1/6 0 3/4 0 0 0 0 0; 1/9 1/6 0 0 13/18 0 0 0 0; 5/36 1/6 0 0 0 25/36 0 0 0; 5/36 1/6 0 0 0 0 13/18 0 0; 1/9 1/6 0 0 0 0 0 13/18 0; 1/12 1/6 0 0 0 0 0 0 3/4]; %closed {1},{2},{3} testIt(p1); end %%%%%%%%%%%%%%%%%%%%%%%%%%%% % % %%%%%%%%%%%%%%%%%%%%%%%%%%%% function testIt(p) [nRow,nCol]=size(p); [closedSet,tranSet]=nmaChainMarkov(p); fprintf('***************************\n\n'); disp(p); if length(closedSet)>0 fprintf('found the following closed sets\n'); emit(closedSet); else fprintf('No closed sets found\n'); end if length(tranSet)>0 fprintf('found the following transient set\n'); emitV2(tranSet); else fprintf('No transient set found\n'); end end %%%%%%%%%%%%%% % % %%%%%%%%%%%%%% function emit(s) for i=1:length(s) c=cell2mat(s{i}(1)); fprintf('{'); for j=1:length(c) fprintf('%d',c(j)); if(j