help-octave
[Top][All Lists]
Advanced

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

Re: Variable Names


From: Judd Storrs
Subject: Re: Variable Names
Date: Tue, 30 Jun 2009 17:21:06 -0400

Without knowing the details of the file types or the numbering scheme it's hard to say. If the filenames are sequentially numbered you could do something like this.

First, if the files aren't some standard file handled by octave or the io or misc packages, the first step I recommend writing a function that takes a file name and returns the data from that one file. Let's call that load_my_data(). Then

data = "" ;

would read the file into data.

Now, to load many of them one approach is to generate filenames using sprintf and store the data in a cell array. Suppose you have 500 files named like "Res2006001" to "Res2006501". Something like this should get you started:

for i=1:500
    name = sprintf("Res2006%03d", i) ;
    data{i} = load_my_data(name) ;
endfor

One thing to be careful of is to make sure that you store data into the cell starting at 1.

If it's difficult to generate the filenames, another option is to store the filenames into a cell array and the load the data using names from the cell array:

filenames = {"Res2006001","Res2006002", ................. , "Res2006501"};
for i=1:length(filenames)
    data{i} = load_my_data(filenames{i}) ;
endfor


--judd


On Tue, Jun 30, 2009 at 4:37 PM, josgau33 <address@hidden> wrote:

Hello all,

I'm trying to write a program I can use to load a large number of data files
into Octave. The files all have the same naming convention:

Res2006001
  ...
Res2006365

Does anyone know if this can be done with an M-file? If so, could you give
me some pointers. Thanks,

Joseph
--
View this message in context: http://www.nabble.com/Variable-Names-tp24279191p24279191.html
Sent from the Octave - General mailing list archive at Nabble.com.

_______________________________________________
Help-octave mailing list
address@hidden
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave


reply via email to

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