From help-octave-request at bevo dot che dot wisc dot edu Mon Mar 11 12:58:06 2002 Subject: Re: sprintf to make filenames From: Douglas Eck To: websterj at acm dot org CC: Mike Miller , Help-Octave List Date: Mon, 11 Mar 2002 19:52:25 +0100 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 -------------------------------------------------------------