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!