|
From: | James Sherman Jr. |
Subject: | Re: loading a file using a variable name |
Date: | Thu, 12 Jul 2007 15:33:41 -0400 |
Hi,
filename = 'exp/fpdata.dat';
load(filename) works, but only of filename is a data file,
not if it sets a couple of variables. In the latter case,
i cannot execute it if i can only refere to the name through
a variable, like just writing filename at the prompt.
Is there a way to do that?
> > datfile = 'xxx.dat'
> > load datfile
> >
> > And to load a file with variables set in it like:
> > var1=100;
> > var2=200;
> >
> > the load command gives an error. Command fopens runs,
> > but then the variables are no loaded, i do not konw how to do that.
> > I know executing the filename works, but if the filename is given
> > by a variable, then i do not know how to execute it.
> > Any idea?
> > Thanks in advance ...
>
> Hi,
> In this case you have to use the functional form of load. Example:
> datfile = 'mmm'
> datfile = mmm
> octave:2> load(datfile)
> octave:3> whos
>
> *** local user variables:
>
> Prot Name Size Bytes Class
> ==== ==== ==== ===== =====
> rw- __nargin__ 1x1 8 scalar
> rwd datfile 1x3 3 string
> rwd mmm 9x2 144 matrix
>
> Total is 22 elements using 155 bytes
>
> ...at least on the old GNU Octave, version 2.1.73.
> Cheers, Avraham
> --
> Please avoid sending to this address attachments in excess of 2MByte,
> or any Excell or Powerpoint attachments.
>
_______________________________________________
Help-octave mailing list
address@hidden
https://www.cae.wisc.edu/mailman/listinfo/help-octave
[Prev in Thread] | Current Thread | [Next in Thread] |