Storing Multiple Matrices from a For Loop
이전 댓글 표시
How do I index and store multiple matrices as a run through a for loop? For instance, I generate a 10x10 matrix the first time through and I want to store this result for access later before proceeding to the next matrix generation.
채택된 답변
추가 답변 (2개)
Saeed Bello
2017년 8월 7일
You can use a three-dimensional matrix e.g.
for i = 1:8 % no. of iteration
S(:, :, i) = myfunx(i,10); % 10 x 10 output
end
Then you can access each iteration by calling S(:, : , 1) or S(:, : , 2) or S(:, : , 3) and so on. Source:https://stackoverflow.com/questions/30036908/output-of-for-loop-as-a-matrix-matlab
댓글 수: 3
Irfan Azhar
2018년 1월 2일
many thanks indeed.
ELIAS PERATICOS
2018년 4월 27일
Saeed Bello, thanks a lot this was very useful.
rees adah
2018년 10월 31일
I also have a similar problem but this solution didn't work for me.i intend to store the matrices coming from a nested for loop into a multidimensional array and reference it later...how do I do that please?
D.K. Rao
2017년 7월 1일
0 개 추천
Thank you very much Cedric Wannaz
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!