How to save in for loops

1 Ansicht (letzte 30 Tage)
Jack_111
Jack_111 am 14 Mai 2013
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 Kommentar
Jan
Jan am 14 Mai 2013
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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Stephan M. H.
Stephan M. H. am 14 Mai 2013
Bearbeitet: Stephan M. H. am 14 Mai 2013
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

Weitere Antworten (1)

Thomas
Thomas am 14 Mai 2013

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by