help-octave
[Top][All Lists]
Advanced

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

Loading multiple files


From: John W. Eaton
Subject: Loading multiple files
Date: Thu, 10 Mar 2005 23:57:41 -0500

On 11-Mar-2005, address@hidden <address@hidden> wrote:

| I'd like to be able to read a large number of files into Octave at once where
| the filenames only differ slightly - file_001.txt, file_002.txt, etc. I've 
been
| using the following code:
| 
| --------
| for i=1:10
|   filename=strcat("file_",sprintf("%03d",i),".txt")
|   eval(["load ",filename]);
| endfor
| --------
| 
| to do this but it's obviously pretty slow due to the use of the eval command.
| Is there a better way to do this?

Yes:

  for i = 1:10
    load (sprintf ("file_%03d.txt", i));
  endfor

jwe



-------------------------------------------------------------
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]