给定for loop
计算一个新的转移矩阵。我正在尝试一个
我想巧妙地重复给定的循环,但一次又一次地复制/粘贴循环是可疑的。请帮忙。
%% generate some weights vector i.e. the probability matrix
Transition =
[
0.06 0.47 0 0.47 0 0 0;
0.47 0.06 0.47 0 0 0 0;
0 0.47 0.06 0.47 0 0 0;
0.47 0 0.47 0.037 0.023 0 0;
0 0 0 0.023 0.037 0.47 0.47;
0 0 0 0 0.47 0.06 0.47;
0 0 0 0 0.47 0.47 0.06
];
tolerance= 0.01
Dij= Transition;
len=length(Transition);
enter code here
%% copying the status
for i=1:7
while(1)
sel=randi(7);
if((Dij(i,sel) ~= 0))
show(i)=sel;
break;
end
end
Dij(i,sel)=Dij(i,sel)-tolerance*(i ~= sel);
for i=1:7
while(1)
sel=randi(7);
if((NewDij(i,sel) ~= 0))
show(i)=sel;
break;
end
end
NewDij(i,sel)=NewDij(i,sel)-tolerance*(i ~= sel);
newnew=NewDij;
end
for i=1:7
while(1)
sel=randi(7);
if((newnew(i,sel) ~= 0))
show(i)=sel;
break;
end
end
newnew(i,sel)=NewDij(i,sel)-tolerance*(i ~= sel);
end
任何帮助表示赞赏。