help-octave
[Top][All Lists]
Advanced

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

Pass arguments from command line


From: John W. Eaton
Subject: Pass arguments from command line
Date: Mon, 27 Aug 2001 10:12:39 -0500

On 27-Aug-2001, Peter He <address@hidden> wrote:

| I'm using Linux Redhat 7.0. I tried to pass some arguments from command
| line to one Octave script file. Here is the script file t1.m:
| 
| #!/usr/bin/octave -qH
| nargin
| argv
| tmp=argv(1)
| 
| Then I try t1.m from shell:
| 
| address@hidden cgshow]$ ./t1.m test 1e-8 0.2
| nargin = 3
| argv =
| (
|    [1] = test
|    [2] = 1e-8
|    [3] = 0.2
| )
| tmp =
| (
|    [1] = test
| )
| 
| Why I couldn't get:
| 
| argv =
| (
|    test
|    1e-8
|    0.2
| )
| tmp =
|    test
| 
| ???
| 
| How can I remove '[?] = ' from argv?

Use nth:

  tmp = nth (argv, 1);


Indexing a list always returns a list.  To do otherwise causes trouble
if the index can sometimes be a scalar and sometimes be a vector or
range.

jwe



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