From help-request at octave dot org Wed Jul 20 08:40:06 2005 Subject: Re: using strings as arguments to load and save From: =?ISO-8859-1?Q?S=F8ren_Hauberg?= To: Nuno Nunes CC: help at octave dot org Date: Wed, 20 Jul 2005 15:39:13 +0200 Hi While I haven't tried this, I guess you could do somewhing like this load("-hdf5", file, "DAY") /Søren Nuno Nunes wrote: > Hi, > > I'm trying to use the load and save commands with a string variable as > the name of the file to work on. I'm very puzzled as to why it works in > one case, but not in others (that would be more useful to me). > > If I write the filename explicitly, the command works as expected, i.e. > loads the variable DAY from HDF5 file nov03.h5m2: > octave:14> load -hdf5 nov03.h5m2 DAY > > Using a string variable as filename, I get an error: > octave:17> file = "nov03.h5m2" > octave:18> load file > error: load: nonexistent file: `file' > > After some experimentation I found that > >>load (file) > > works (i.e. the variable file expands to nov03.h5m2), except it loads > all variables (which I want to avoid with 7 GB files...) If I specify > the variable, I get a syntax error: > octave:18> load (file) DAY > parse error: > > syntax error > > >>>>load (file) DAY > > ^ > octave:18> load -hdf5 (file) DAY > error: load: nonexistent file: `(file)' > > I couldn't find any documentation of this behaviour, and now I ran out > of ideas to try to get the variable string to expand to its value. Has > anyone managed to do this? How is it done? Am I doing anything wrong? > Any help will be greatly appreciated. > > Thanks, > Nuno > > > > ------------------------------------------------------------- > 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 -------------------------------------------------------------