help-octave
[Top][All Lists]
Advanced

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

RE: loading a file using a variable name


From: Hall, Benjamin
Subject: RE: loading a file using a variable name
Date: Thu, 12 Jul 2007 17:08:46 -0400

source(filename) 

-----Original Message-----
From: address@hidden [mailto:address@hidden 
Sent: Thursday, July 12, 2007 4:33 PM
To: James Sherman Jr.
Cc: octave
Subject: Re: loading a file using a variable name

But it wont work if the filename hast a directory path in it, like
filename = 'inputs/variables.m'
eval(sprintf("%s", filename ))

Is there a way to overcome it?


On 7/12/07, address@hidden <address@hidden> wrote:
> > If on the other hand you wanted a script that declared var1 and var2 as
> > above, you could put (like David said) the lines:
> > var1 = 100;
> > var2 = 200;
> > in a file called "var.m", then (assuming it is in your present directory
or
> > path) type
> > > var
> > at the command line.
>
> yes I want this, but the file name, in this case var, should be
> given by a variable. I solved it with:
> octave> filename='var'
> octave> eval(sprintf("%s", filename ))
>
_______________________________________________
Help-octave mailing list
address@hidden
https://www.cae.wisc.edu/mailman/listinfo/help-octave


reply via email to

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