问题
global m = 1;
function p = h()
m
end
h()
I'm trying to run this script, but I get this error:
'm' undefined near line 4 column 3
Say me please, how I can use the variable from functions?
回答1:
You have to declare the var also global inside the function as described here: https://www.gnu.org/software/octave/doc/interpreter/Global-Variables.html
global m = 1;
function p = h()
global m;
m
endfunction
h()
来源:https://stackoverflow.com/questions/27409364/global-variable-in-octave