Main Content

getWorkspace

Class: Simulink.Mask
Namespace: Simulink

Create mask workspace object

Since R2025a

Syntax

workspaceObj = maskObj.getWorkspace

Description

workspaceObj = maskObj.getWorkspace creates an object of Simulink.Mask.Workspace. Use workspaceObj to access the variables, parameters and their values in a mask workspace.

Output Arguments

expand all

Variables, parameters and their values in a mask workspace, returned as an object of Simulink.Mask.Workspace.

Examples

Get Mask Workspace Parameters and Variables

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