help-octave
[Top][All Lists]
Advanced

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

Re: giving arguments when calling an octave script


From: David Bateman
Subject: Re: giving arguments when calling an octave script
Date: Fri, 13 Jul 2007 14:39:17 +0200
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

address@hidden wrote:
> Hi,
> how to send arguments to the script scriptname.oct like:
>
> shell#  octave scriptname.oct ARG1, ARG2 ...
>
> Thanks in advance and for all help up to now ...
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www.cae.wisc.edu/mailman/listinfo/help-octave
>
>   


Note you are confusing a script (executed in the current workspace and
so has access to the variable in the current workspace), and a function
(creates its own workspace and so the variables in the current workspace
are out of scope).

The do what you want in octave 2.9.x do

octave --eval scriptname(ARG1, ARG2)

Doing it in 2.1.x requires some modification of the function, which I
believe is only possible for a script file (not a function). Add the
following code the the m-file script

if length(argv)
ARG1= argv{1};
ARG2= argv{2};
endif

and then run the script from the command line like

octave scriptname.m 'arg1' 'arg2'

D.

-- 
David Bateman                                address@hidden
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary



reply via email to

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