Global
The global keyword is used to declare a variable as being in the global scope – that is, always visible and changeable. The variable must be declared as global in each context in which it is used.
function ChangeA(new_val)
global a
a=new_val
end
…
global a
a=5
ChangeA(9)
disp(a)
At the end of this code snippet, the value that is printed out is 9.
Global variables are initialized to an empty matrix the first time they are declared. If a global variable already exists and is redeclared, its value is left unchanged.