MATLAB:马尔科夫矩阵

[m,n]=size(citylight);
R=zeros([m,n]);
M=mean(citylight);
%等级划分
for i=1:n %年份
    for j=1:m %城市
        if citylight(j,i)<=0.5*M(i)
            R(j,i)=1;
        elseif citylight(j,i)>0.5*M(i) && citylight(j,i)<=M(i)
            R(j,i)=2;
        elseif citylight(j,i)>M(i) && citylight(j,i)<=2*M(i)
            R(j,i)=3;
        elseif citylight(j,i)>2*M(i)
            R(j,i)=4;
        end
    end
end