马尔科夫链%ThisisprogrammedforcalculatingtheMarkov-chainstatetransferprobability(Firstorder)matrice!%Thisprogramisbasedon4thresholds,thatis,thetransferprobabilitymatriceis4x4.%Followthenotestoconducttheprocessing.%CodedbyEOS%NanchangChinaclearclc%A=csvread('widetype.csv');%%ormanuallydefineviaA=[].A=[]%Aistheinformationmatrixwhichmustbeadjustedtowide-type,i(section)-j(time)%%out=zeros(4,4);%Initializethetransferingprobability(Firstorder)matrice[r1,r2,r3]=deal(1.009,1.285,1.7256);%%!!!Definethestatethresholdvaluemanually.flag=0;trans=zeros(4,4);s0=zeros(1,4);epro=zeros(10,4);fori=1:10ifA(i,1)r1s0(1,1)=s0(1,1)+1;elseifA(i,1)=r1&&A(i,1)r2s0(1,2)=s0(1,2)+1;elseifA(i,1)=r2&&A(i,1)r3s0(1,3)=s0(1,3)+1;elses0(1,4)=s0(1,4)+1;endendfori=1:10fort=1:14ifA(i,t)r1epro(i,1)=epro(i,1)+1;elseifA(i,t)=r1&&A(i,t)r2epro(i,2)=epro(i,2)+1;elseifA(i,t)=r2&&A(i,t)r3epro(i,3)=epro(i,3)+1;elseepro(i,4)=epro(i,4)+1;endendendfors=1:10fort=1:13%%withinaninitialstate1ifA(s,t)r1flag=1;ifA(s,t+1)r1trans(flag,1)=trans(flag,1)+1;elseifA(s,t+1)=r1&&A(s,t+1)r2trans(flag,2)=trans(flag,2)+1;elseifA(s,t+1)=r2&&A(s,t+1)r3trans(flag,3)=trans(flag,3)+1;elsetrans(flag,4)=trans(flag,4)+1;end%%withinaninitialstate2elseifA(s,t)=r1&&A(s,t)r2flag=2;ifA(s,t+1)r1trans(flag,1)=trans(flag,1)+1;elseifA(s,t+1)=r1&&A(s,t+1)r2trans(flag,2)=trans(flag,2)+1;elseifA(s,t+1)=r2&&A(s,t+1)r3trans(flag,3)=trans(flag,3)+1;elsetrans(flag,4)=trans(flag,4)+1;end%%withinaninitialstate3elseifA(s,t)=r2&&A(s,t)r3flag=3;ifA(s,t+1)r1trans(flag,1)=trans(flag,1)+1;elseifA(s,t+1)=r1&&A(s,t+1)r2trans(flag,2)=trans(flag,2)+1;elseifA(s,t+1)=r2&&A(s,t+1)r3trans(flag,3)=trans(flag,3)+1;elsetrans(flag,4)=trans(flag,4)+1;end%%withinaninitialstate4elseflag=4;ifA(s,t+1)r1trans(flag,1)=trans(flag,1)+1;elseifA(s,t+1)=r1&&A(s,t+1)r2trans(flag,2)=trans(flag,2)+1;elseifA(s,t+1)=r2&&A(s,t+1)r3trans(flag,3)=trans(flag,3)+1;elsetrans(flag,4)=trans(flag,4)+1;endendendend%CalculatetheMarkovstatetransferingprobabilitymatricefori=1:4forj=1:4out(i,j)=trans(i,j)/sum(trans(i,:));endenddisp('Markovstatetransferingprobabilitymatriceis:')disp(out)