MATLAB: Debugging a nested function

debugMATLABnested functionstatic workspace

Hello!
I have created a code with nested functions in it. My problem is, that when I am in debugging mode and try to create a variable for testing certain values, matlab gives the following error:
Attempt to add "test" to a static workspace.
See MATLAB Programming, Restrictions on Assigning to Variables for details.
It is really bothering, because I create test variables all the time during debug mode. Is there a solution for that, where I can do so?

Best Answer

Peter - see variables in nested and anonymous functions for a description of the problem and possible solutions (the suggestion is to use global variables). On the other hand, why do you want to create new variables? Can't you just use the Command Window to display the current state/value of the variables?