help-octave
[Top][All Lists]
Advanced

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

global variable question


From: Christoph Dalitz
Subject: global variable question
Date: Mon, 8 Dec 2003 16:05:42 +0100

Hello,

I am having trouble with the use of global variables in Octave 2.1.35.

 (a) Subsequent initializations of global variables are ignored, eg.

        global n = 10;
        global n = 100;  # has no effect

     This happens for instance when a script is called a second time
     after it has been edited.

 (b) It seems to be impossible to declare more than one variable global
     per line, eg.

        global n = 500;
        global r = 0.95;

        function y = f(p)
          global r,n;
          y = 1 - binomial_cdf(round(r*n),n,p);  # error: `n' undefined
        endfunction

     Actually I would not care, because with a second "global" statement for
     the variable n the above example works.

     I wonder however, whether I am missing something, because the manual
     explicitly gives examples of the form

        global c = 3, d, e = 5

Any hints for enlightenment welcome.

Christoph



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