help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: saving matrices - question on naming save file


From: James Sherman Jr.
Subject: Re: saving matrices - question on naming save file
Date: Wed, 17 Mar 2010 11:30:51 -0400

If you want a different file for every new matrix, you could do something like:

for i = 1:100,
   M = <whatever you want to do>
   filename = sprintf('matrix%03d.mat', i);
   save(filename, 'M');
end

or if you wanted them all in one file, I'd save them in one big variable (assuming that they're all the same size, and 2D)

allM = zeros([100, size(M)]);
filename = 'allM.mat';

for i = 1:100,
   M = <whatever you want to do>
   allM(i, :, :)  = M;
end

save(filename, 'allM');  

On Wed, Mar 17, 2010 at 11:10 AM, Richard Evans <address@hidden> wrote:
I want to go through a FOR loop a hundred times and alter a matrix each time, saving the resulting matrix with each pass through the loop.
 
Is there a way to increment the file name so that it does not overwrite itself each time?  I hope this can be done in Octave, but I'm not sure...
 
Rick


_______________________________________________
Help-octave mailing list
address@hidden
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave



reply via email to

[Prev in Thread] Current Thread [Next in Thread]