The character vector, 'plot(rand(20,3))', is a valid command, and MATLAB
evaluates it when the user clicks the button. If the character vector includes a variable,
for example,
'plot(x)'
The variable x must exist in the base workspace when the user triggers the callback, or it
returns an error. The variable does not need to exist at the time you assign callback
property value, but it must exist when the user triggers the callback.
Unlike callbacks that are specified as function handles or cell arrays, MATLAB does not
check character vectors for syntax errors or missing dependencies. If there is a problem
with the MATLAB expression, it remains undetected until the user triggers the callback.
See Also
Related Examples
- “Callbacks for Specific Components” on page 7-12
- “Share Data Among Callbacks” on page 11-2
- “Interrupt Callback Execution” on page 12-2
- “Anonymous Functions”
10 Code a Programmatic App