To clearly describe what I mean, I'll just give an example:
function y = f(x,a)
global a
y = f1(x);
function y = f1(x)
global a
y = x + a;
Here I want the variable 'a' to be used as a global variable that can be called by the subfunction 'f1' to compute $ x + a $. (My goal is to reduce parameter conversion)
But this function does not work if I do not define a new variable 'b' to restore the value of 'a'.
The question is, how can I make the 'a' global variable directly without defining a new variable?
source
share