help-octave
[Top][All Lists]
Advanced

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

Re: loading incremented files


From: Dirk Eddelbuettel
Subject: Re: loading incremented files
Date: Fri, 16 Jun 2000 14:34:36 -0400
User-agent: Mutt/1.0.1i

James,

On Fri, Jun 16, 2000 at 01:30:04PM -0400, James Cooley wrote:
> I would like to have octave load each file individually, do some
> processing, save a value and load the next to continue the cycle.  I
> have tried making a string variable which would increment the file,
> e.g.,
> 
> for i=1:100
> temp = ['stuff',i,'.dat']
> load -ascii temp
> end
> 
> but this tries to load the file 'temp' not stuff#.dat.  How can I get
> octave to load each file individually without doing it manually???

Wrap it into a call to eval(). Eg

for i = 1:100
    cmdstr = sprintf("load -ascii stuff%d");
    eval(cmdstr);
    # do stuff
end

should work. Of course, you can put the sprintf inside of eval, but I like
to inspect the generated string first.

Regards, Dirk

-- 
According to the latest figures, 43% of all statistics are totally worthless.



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

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



reply via email to

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