help-octave
[Top][All Lists]
Advanced

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

Re: using a global variable as default argument


From: Doug Stewart
Subject: Re: using a global variable as default argument
Date: Sun, 23 Mar 2014 12:47:18 -0400




On Sun, Mar 23, 2014 at 12:29 PM, Erik Leunissen <address@hidden> wrote:
Darn. Another typo. Sorry, I'm hazy today.

Once more corrected.


Erik Leunissen.
--



-- script file tst.m --
function rv = f(v=pi)
    rv = v;

endfunction
--

> tst
> f()
ans =  3.1416


OK, that works. However, the following doesn't:

-- script file tst.m --
global myconst = 1.2345;



## try this: 
function rv = f()
       global myconst;
        v=myconst;
    rv=v;

endfunction
--

> tst
> f()
error: 'myconst' undefined near line 3 column 19

_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave



--
DASCertificate for 206392


reply via email to

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