For the program, for example:
function output = input(n)
global SAVER;
SAVER = zeros(n,n,20);
*other code here*
output = SAVER(:,:,5)
When this is run in the command window (by input(5)
for example), the variable ans
appears in the workspace.
However, I was under the impression that because SAVER
was declared as a global variable, it would also be saved globally and would be accessible from the workspace.
However, when I type SAVER(:,:,2)
for example in the command window after running input(n)
I get the error message Undefined function or variable 'SAVER'
.
Is it possible to access the different elements in SAVER
from the command window after running the function, and is this not what a global variable does?