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 view (last 30 days)
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

Accepted Answer

John Chilleri
John Chilleri on 12 Jan 2017
Edited: John Chilleri on 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 Comments
John Chilleri
John Chilleri on 12 Jan 2017
Edited: John Chilleri on 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.

Sign in to comment.

More Answers (0)

Categories

Find more on Just for fun in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!