Main Content

Simulink.Mask.Workspace Class

Mask workspace object

Since R2025a

Description

Create an object of Simulink.Mask.Workspace by using getWorkspace method. Use the get method to display the values of the mask workspace variables, parameters. Set the values of mask workspace variables and parameters using the set method in the Mask initialization function of the mask callback file only. You cannot set the values of the variables and parameters outside of mask initialization code.

The Simulink.Mask.Workspace class is a handle class.

Examples

collapse all

Get and set the value of a mask workspace parameter

Load the model and create a mask object.

open_system("slexMaskingBasic.slx");
maskObj = Simulink.Mask.get("slexMaskingBasic/mx + b");

Create a mask workspace object.

workspaceObj = maskObj.getWorkspace
workspaceObj = 
  Workspace with no properties.

Display the value of the mask parameter m.

workspaceObj.get("m")
ans = 
5

Set the values of mask workspace variables and parameters by using the set method in the Mask initialization function of the mask callback file.

workspaceObj.set("m",10)

maskinit-set.png

Note: You cannot set the values of the variables and parameters outside of mask initialization code.

Version History

Introduced in R2025a