help-octave
[Top][All Lists]
Advanced

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

Re: load command question


From: Stefan van der Walt
Subject: Re: load command question
Date: Mon, 8 May 2006 02:49:34 +0200
User-agent: Mutt/1.5.11

On Sun, May 07, 2006 at 07:04:43PM -0500, Quentin Spencer wrote:
> Myriam Abramson wrote:
> 
> >How do I load a file with a variable name?
> >
> >
> >octave> mypattern
> >mypattern = random4.out
> >octave> mypattern
> >mypattern = random4.out
> >octave> load mypattern
> >error: load: couldn't open input file `mypattern'
> >octave> load "mypattern"
> >error: load: couldn't open input file `mypattern'
> >octave> 

A useful trick is to build command lines from strings.  For example,
if you have

x = "1"
filename = "myfile"

you can do

exec(["load(", filename, x, ".dat)"])

which will execute

load(myfile1.dat)

Regards
Stéfan


reply via email to

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