Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Save command

Subject: Save command

From: M K

Date: 12 May, 2009 13:39:02

Message: 1 of 2

i would like to save two arrays, x and y in a script file. these two
variables are dependent on a value A.
 I am using the following command

save variable x y

when I run the script file again for a different value of A, I'd like it
the filename to indicate the value of A so for example

when A =1 filename == variable1
         A =2 filename == variable2 etc

Is this possible using the save command?
thanks for your help.

Subject: Save command

From: Steven Lord

Date: 12 May, 2009 14:17:11

Message: 2 of 2


"M K" <maha_k@mathworks.com> wrote in message
news:gubu5l$95f$1@fred.mathworks.com...
>i would like to save two arrays, x and y in a script file. these two
> variables are dependent on a value A.
> I am using the following command
>
> save variable x y
>
> when I run the script file again for a different value of A, I'd like it
> the filename to indicate the value of A so for example
>
> when A =1 filename == variable1
> A =2 filename == variable2 etc
>
> Is this possible using the save command?
> thanks for your help.

A = 5;
thefile = fprintf('MyMatFileNumber%d.mat', A);
save(thefile, 'A')

--
Steve Lord
slord@mathworks.com

Tags for this Thread

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.

Contact us