help-octave
[Top][All Lists]
Advanced

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

Re: input variables form the shell


From: c.
Subject: Re: input variables form the shell
Date: Thu, 1 Mar 2012 22:07:31 +0530

On 1 Mar 2012, at 21:27, jacopo rocchi wrote:

> Hi, is it possible to launch an octave script passing arguments from the
> shell?
> 
> I would liko to do something like this:
> 
> write this in the shell: >octave -q script.m ARG
> And then inside script.m i would write something like this: disp(2*ARG);

in the file script.m write:

function script (ARG)
  disp (2*ARG)
endfunction

then launch octave like this:
$ octave -qf --eval "script (2.0)"
 4


> So I would like the script to print to the shell 2 times the argument passed
> in input.
> 
> I read I should use the argv function but I mean, what is the correct
> syntax?

if you still think you need argv, its syntax is described in the manual:
http://www.gnu.org/software/octave/doc/interpreter/Command-Line-Options.html#doc_002dargv

you might also be interested in this:
http://www.gnu.org/software/octave/doc/interpreter/Executable-Octave-Programs.html#Executable-Octave-Programs

c.





reply via email to

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