Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

global variable in octave

Tags:

global

octave

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?

like image 648
Andrew Avatar asked Dec 10 '14 19:12

Andrew


Video Answer


1 Answers

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()
like image 87
Andy Avatar answered Sep 19 '22 14:09

Andy