MATLAB: Does ASSIGNIN assign a value in the MATLAB base workspace rather than mask workspace when setting a value within the mask initialization callback in Simulink 7.0 (R2007b)

assignssimulink

My model example.mdl contains a masked subsystem. The mask initialization for this subsystem makes a call to a custom MATLAB function in which I use ASSIGNIN to set the value of a parameter in the 'caller' workspace. I expect that the 'caller' workspace is the mask workspace. However, when I run the model and then execute WHOS at the MATLAB command prompt, I find that the variable is assigned in the MATLAB base workspace.

Best Answer

Documentation on how ASSIGNIN works with Simulink's mask workspace is missing from the product manual.
ASSIGNIN is a builtin MATLAB function that has been designed to work with MATLAB workspaces. The mask workspace is not a MATLAB workspace. Hence, when the mask initialization function calls ASSIGNIN, the variable is assigned to the MATLAB base workspace.
In order to read or write mask workspace variables, use SET_PARAM or GET_PARAM with the 'MaskWSVariables' parameter.