Section: Variables and Arrays
global statement
is
global variable_1 variable_2 ...
The global statement must occur before the variables
appear.
set_global.m
function set_global(x)
global common_array
common_array = x;
The second function retrieves the value from the global variable
get_global.m
function x = get_global
global common_array
x = common_array;
Here we exercise the two functions
--> set_global('Hello')
--> get_global
ans =
<string> - size: [1 5]
Hello