I define a variable "p" in the base workspace either in the Command Window or by loading from a MAT-file:
p=666;
Then I create a script containing the following code:
x=@(g) g+p;
When I run the script, then try to use my anonymous function, I receive the following error:
x(49)
??? Undefined function or variable 'p'.
Why is this error occurring?
Best Answer