help-octave
[Top][All Lists]
Advanced

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

Re: sprintf to make filenames


From: Douglas Eck
Subject: Re: sprintf to make filenames
Date: Mon, 11 Mar 2002 19:52:25 +0100
User-agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.6) Gecko/20011120

You can also use the functional version of save:

a=rand(1,5);
fname="foo.mat"
save("-ascii",fname,"a");

saves the variable "a" to the file "foo.mat" as ascii.

Cheers,
Doug

f
Jonathan C. Webster wrote:

Mike Miller wrote:


Hello all--

I want to be able to use the usual save command of this form:

save -ascii file_0001.dat matrixdata

but I'd like for the filename to be determined by a variable in this sort
of way:








That does work.  Here is an example:  "runNo" and "data_to_save"  are
defined  by your code.



fnam_t= sprintf("%s.type",runNo);

str = sprintf("save %s  data_to_save",fnam_t);

eval(str);

Hope that helps.

Jonathan



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------







-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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