MATLAB: Does the uicontrol ‘Callback’ execute in the base workspace in MATLAB 7.0.1 (R14SP1)

basecallbackfunctionMATLABuicontrolworkspace

When I create a uicontrol object from the command line and assign a statement to execute in the form of a string as shown below, the statement executes in the base workspace instead of a separate function workspace.
h=uicontrol('Callback','a=10');
When I click the push button, the value of "a" in the base workspace is overwritten and "a" is now equal to 10.

Best Answer

This is not a bug. This is the intended and documented behavior. Callback routines execute in the base workspace if the value of the Callback property is specified as a string. Callback routines execute in a separate function workspace if the value of the Callback property is specified as a function handle as shown below.
h=uicontrol('Callback',@callback_function)