Total Number of 24 matrix (3*3) but this code show only one matrix 3*3 how to see full iteration in command window
1 次查看(过去 30 天)
显示 更早的评论
Arr=100; POpu=3; TAppi=3; XLb=50; XUp=100; for Arr=1:Arr for i=1:3 for j=1:3 Pare(i,i)=XLb+rand(1)*(XUp-XLb); %Calculating Initally Generated Number% end end end
0 个评论
采纳的回答
John Chilleri
2017-1-12
编辑:John Chilleri
2017-1-12
I'm not entirely sure of your problem, but if you're trying to keep all of the Pare matrices generated, try this:
Arr=100;
POpu=3;
TAppi=3;
XLb=50;
XUp=100;
for Arr=1:Arr
for i=1:3
for j=1:3
Pare(i,j,Arr)=XLb+rand(1)*(XUp-XLb);
% Calculating Initally Generated Number
end
end
end
You're overwriting the Pare matrix each step so you lose the previous one, the above code saves all of them.
Also, do you mean Pare(i,i) or Pare(i,j)?
Hope this helps!
2 个评论
John Chilleri
2017-1-12
编辑:John Chilleri
2017-1-12
Also, a simpler solution to your problem is:
Arr=100;
POpu=3;
TAppi=3;
XLb=50;
XUp=100;
Pare = XLb + rand(3,3,Arr)*(XUp-XLb);
Also, did you want to say for i = 1:3 or 1:P0pu/1:TAppi, or in this case, rand(P0pu,TAppi,Arr)? I ask because if you attempt to use this in the future and change P0pu/TAppi to see nothing changes, you'll know why.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!