How to save in for loops

조회 수: 1 (최근 30일)
Jack_111
Jack_111 2013년 5월 14일
I have 50 matrices and I am taking the average of them using for loop and this loop is inside another loop running for 30 times and I want to save the results for each one of these 30 seperately. How can I do it?
  댓글 수: 1
Jan
Jan 2013년 5월 14일
Please use meaningful tags.
While it is clear for you, what "I have 50 matrices" exactly mean, we cannot guess this and posting an example requires time-consuming guessing, what you could mean. Please be more specific.

댓글을 달려면 로그인하십시오.

채택된 답변

Stephan M. H.
Stephan M. H. 2013년 5월 14일
편집: Stephan M. H. 2013년 5월 14일
Hi Yaman,
from your description I guess your code looks something like this:
for n=1:30
% your different set of 50 matrices in each of the 30 loops
matrix_array(:,:,50)= load(...)
for l=1:50
average_matrix = ... % build average of matrices
end
%ADD THESE LINES AT THE END OF THE OUTER FOR-LOOP
savestring = strcat('avg_matrix',num2str(n));
save(savestring,'average_matrix')
end
That should do it.
best, Stephan

추가 답변 (1개)

Thomas
Thomas 2013년 5월 14일

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by