From help-octave-request at bevo dot che dot wisc dot edu Sun Dec 24 04:53:34 2000 Subject: Re: newbie argv questions From: Paul Kienzle To: swest at as dot arizona dot edu Cc: help-octave at bevo dot che dot wisc dot edu Date: Sat, 23 Dec 2000 00:33:29 +0000 On Fri, Dec 22, 2000 at 09:35:27PM -0000, swest at as dot arizona dot edu 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,:) > > 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 pkienzle at kienzle dot powernet dot co dot uk ------------------------------------------------------------- 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 -------------------------------------------------------------