help-octave
[Top][All Lists]
Advanced

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

How to share variables between functions


From: Evan
Subject: How to share variables between functions
Date: Tue, 3 Apr 2007 13:38:25 +0800

In some cases, it seems that sharing variables between functions
cannot be avoidable. for example

function y=f(x)
   global x;
   y=quad(subf,0,1);
   clear x;
endfunction

function f=subf(t)
   global x;
   f=g(x,t);
endfunction

function y=g(x,t)
   ......
endfunction

because "quad" function only accept functions with one scalar
argument, other arguments have to be passed by other means. The only
way I know is to use global variables as the above example does. But I
don't think it is a good idea for that the variable "x" would also be
accessible elsewhere, thus confusion may be caused. Is there any
method to share local variables between functions, that is, these
variables are not visible elsewhere?

Thanks in advance


reply via email to

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