end
end
Alternatively, assign the output from the load function to a structure array.
Assigning a Variable in the MATLAB Debugger in a Nested Function
While debugging, you cannot add a variable using the debug command prompt if you are stopped in a
nested function. Assign the variable into the base workspace, which is not static.
K>> assignin('base','X',myvalue)
Assigning a Variable in an Anonymous Functions
Anonymous functions cannot contain variable assignments. When the anonymous function is called an
error will be thrown.
% This will error since 'x' is being assigned inside
% the anonymous function
@()eval("x=2")
Rewrite the function in such a way that variable assignments are not required.
xEquals2 = @()2;
x = xEquals2()
x =
2
See Also
More About
•
“Base and Function Workspaces” on page 20-9
•
“Nested Functions” on page 20-27
Resolve Error: Attempt to Add Variable to a Static Workspace.
20-35
end
Alternatively, assign the output from the load function to a structure array.
Assigning a Variable in the MATLAB Debugger in a Nested Function
While debugging, you cannot add a variable using the debug command prompt if you are stopped in a
nested function. Assign the variable into the base workspace, which is not static.
K>> assignin('base','X',myvalue)
Assigning a Variable in an Anonymous Functions
Anonymous functions cannot contain variable assignments. When the anonymous function is called an
error will be thrown.
% This will error since 'x' is being assigned inside
% the anonymous function
@()eval("x=2")
Rewrite the function in such a way that variable assignments are not required.
xEquals2 = @()2;
x = xEquals2()
x =
2
See Also
More About
•
“Base and Function Workspaces” on page 20-9
•
“Nested Functions” on page 20-27
Resolve Error: Attempt to Add Variable to a Static Workspace.
20-35
