Main Content

Control System Mask Programmatically

Simulink® defines a set of parameters to configure and edit a system mask.

  • addParameter

  • removeParameter

  • removeAllParameters

  • MaskParameter.Name

Note:

  • Adding, removing, and renaming parameters on a system mask using these methods is not supported for a model mask.

Simulink.Mask.create

Use the Simulink.Mask.create method to create mask on a model. The syntax to mask a model,

  • Using the model name

Simulink.Mask.create(ModelName)

  • Using the system handle

SystemHandle = get_param(gcs,'Handle') %To get the system handle

Simulink.Mask.create(SystemHandle) %To create mask using system handle

Example:

new_system('vdp');
save_system;
maskObj = Simulink.Mask.create('vdp')
maskObj = 
  Mask with properties:

                         Type: 'vdp'
                  Description: ''
                         Help: ''
               Initialization: ''
               SelfModifiable: 'off'
                    ImageFile: ''
                      Display: ''
                    IconFrame: 'on'
                   IconOpaque: 'opaque'
         RunInitForIconRedraw: 'analyze'
                   IconRotate: 'none'
                   PortRotate: 'default'
                    IconUnits: 'autoscale'
                   Parameters: [0x0 Simulink.MaskParameter]
              PortIdentifiers: [0x0 Simulink.Mask.PortIdentifier]
         ParameterConstraints: [0x0 Simulink.Mask.Constraints]
    CrossParameterConstraints: [0x0 Simulink.Mask.CrossParameterConstraints]
              PortConstraints: [0x0 Simulink.Mask.PortConstraint]
                     BaseMask: [0x0 Simulink.Mask]

Simulink.Mask.get

Use the Simulink.Mask.get method to get the mask on a model as a mask object. The syntax to get the existing mask of a model,

  • Using the model name

Simulink.Mask.get(ModelName)

  • Using the system handle

SystemHandle = get_param(gcs,'Handle') %To get the system handle

Simulink.Mask.get(SystemHandle) %To create mask using system handle

Example:

maskObj = Simulink.Mask.get('vdp')
maskObj = 
  Mask with properties:

                         Type: 'vdp'
                  Description: ''
                         Help: ''
               Initialization: ''
               SelfModifiable: 'off'
                    ImageFile: ''
                      Display: ''
                    IconFrame: 'on'
                   IconOpaque: 'opaque'
         RunInitForIconRedraw: 'analyze'
                   IconRotate: 'none'
                   PortRotate: 'default'
                    IconUnits: 'autoscale'
                   Parameters: [0x0 Simulink.MaskParameter]
              PortIdentifiers: [0x0 Simulink.Mask.PortIdentifier]
         ParameterConstraints: [0x0 Simulink.Mask.Constraints]
    CrossParameterConstraints: [0x0 Simulink.Mask.CrossParameterConstraints]
              PortConstraints: [0x0 Simulink.Mask.PortConstraint]
                     BaseMask: [0x0 Simulink.Mask]

Note:

To get the model mask as a mask object in the mask callback, you can use Simulink.Mask.get() without passing a system name or system handle. Simulink fallback for tm_simulink does not require the system name (gcb) or the system handle (gcs) to query the mask object for the model mask.

Related Topics