MATLAB: How to have a To Workspace block inside a masked library block write to a user specified variable in Simulink 7.6 (R2010b)

simulink

I have a masked library block that contains a To Workspace block. I specify a desired workspace output variable the mask called ThisSimulation.
Inside the mask editor, I set the mask parameter to write ThisSimulation to DesiredName. When I set the To Workspace block to use DesiredName, it writes the variable to DesiredName instead of ThisSimulation.

Best Answer

The Variable Name field in the To Workspace block does not evaluate its contents. It takes the literal string that is present and writes to the workspace a variable with a name of that literal string.
It is possible to use a set_param command inside the mask initialization commands to set the value used in the Variable Name field in the To Workspace block. The attached model demonstrates this.
Related Question