Thread Subject: saving withina loop

Subject: saving withina loop

From: M K

Date: 15 Sep, 2009 10:12:01

Message: 1 of 2

Hi

I want to save a matrix within a loop with a filename associated with the loop number so for ex

for k=1:10
   matrix

  save matrix1 % or matrix2 matrix3 and so on with increasing loop number

end

How can I make the filename dependent on the loop number?

thanks

Subject: saving withina loop

From: Image Analyst

Date: 15 Sep, 2009 10:25:20

Message: 2 of 2

"M K" <maha_k@mathworks.com> wrote in message <h8np9h$k9t$1@fred.mathworks.com>...
> Hi
>
> I want to save a matrix within a loop with a filename associated with the loop number so for ex
>
> for k=1:10
> matrix
>
> save matrix1 % or matrix2 matrix3 and so on with increasing loop number
>
> end
>
> How can I make the filename dependent on the loop number?
>
> thanks
-----------------------------------------------------------------------------------------------------------
Use sprintf() to generate filenames that depend on your loop number, or any other variables. It's simple - it works just like the sprintf() you're already famiiliar with in C.
E.g.:

baseFileName = sprintf('matrix %d', k);
fullFileName = fullfile(folder, baseFileName); % Prepend the path/folder

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
save filename loop M K 15 Sep, 2009 06:14:02
rssFeed for this Thread

Contact us at files@mathworks.com