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 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
shane watson
am 12 Jan. 2017
Bearbeitet: John Chilleri
am 12 Jan. 2017
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 Kommentare
Akzeptierte Antwort
John Chilleri
am 12 Jan. 2017
Bearbeitet: John Chilleri
am 12 Jan. 2017
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 Kommentare
John Chilleri
am 12 Jan. 2017
Bearbeitet: John Chilleri
am 12 Jan. 2017
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.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!