help-octave
[Top][All Lists]
Advanced

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

Re: newbie argv questions


From: Paul Kienzle
Subject: Re: newbie argv questions
Date: Sat, 23 Dec 2000 00:33:29 +0000
User-agent: Mutt/1.2.5i

On Fri, Dec 22, 2000 at 09:35:27PM -0000, address@hidden wrote:
> I am completely new to Octave.  I'm switching from many years of
> MathCad.
> 
> I'm writing a stand-alone script that passes 2 files on the command
> line, but am having some problems with argv.  I've checked the Octave
> docs on the website, but cannot find a discussion that answers my
> questions.
> 
> It appears that I cannot simply open the files with:
> 
> load (argv(i,:)), etc  since the length of each string in argv is set
> to the maximum length of the longest string in the parameter list. 
> This causes the appending of extra spaces on the end of arguments that
> are shorter--which seems to deny file name matches in glob.
> 
> So I am now using:
> 
> load (sscanf (argv(i,:), '%s', Inf))  which properly gets just the
> non-space string portion of the argument.  Do I really have to do
> this?

load(deblank(argv(i,:)))

> 
> Now load seems to assign a name to the data array in the file that is
> the file name itself.
> 
> However, typing  argv(1,:) <CR>
> 
> doesn't print the array elements that were in the file, but just the
> array name.  How do I print the array elements?

eval(argv(1,:))

or better yet

eval(["v1=",argv(1,:),";"]);

which puts the array in v1 so you don't have to manipulate it with
eval's all the time.  Assignment in Octave is lazy (that is, the array
is only copied if one of the variables referencing it is modified), so
this won't take any extra memory.

> 
> Thanks much--just having some culture shock from MathCad to Octave...
> 
> swest
> 

Paul Kienzle
address@hidden



-------------------------------------------------------------
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
-------------------------------------------------------------



reply via email to

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