Main Content

Control Model Mask Programmatically

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

Note

Adding, removing, and renaming parameters on a model mask using these methods is not supported:

  • addParameter

  • removeParameter

  • removeAllParameters

  • MaskParameter.Name

Simulink.Mask.create

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

  • Using the model name:

    Simulink.Mask.create(ModelName)
  • Using the model handle

    ModelHandle = get_param(gcs,'Handle') %To get the model handle
    Simulink.Mask.create(ModelHandle) %To create mask using model handle

An example follows,

maskObj = Simulink.Mask.create('vdp');
                    Type: 'vdp'
             Description: 'The van der Pol Equation…'
                    Help: ''
          Initialization: ''
          SelfModifiable: 'off'
                 Display: ''
               IconFrame: 'on'
              IconOpaque: 'opaque'
    RunInitForIconRedraw: 'off'
              IconRotate: 'none'
              PortRotate: 'default'
               IconUnits: 'autoscale'
              Parameters: [0×0 Simulink.MaskParameter]
                BaseMask: [0×0 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 is,

  • Using the model name:

    Simulink.Mask.get(ModelName)
  • Using the model handle

    ModelHandle = get_param(gcs,'Handle') %To get the model handle
    Simulink.Mask.get(ModelHandle) %To create mask using model handle

An example follows:

maskObj = Simulink.Mask.get('vdp');
                    Type: 'vdp'
             Description: 'The van der Pol Equation…'
                    Help: ''
          Initialization: ''
          SelfModifiable: 'off'
                 Display: ''
               IconFrame: 'on'
              IconOpaque: 'opaque'
    RunInitForIconRedraw: 'off'
              IconRotate: 'none'
              PortRotate: 'default'
               IconUnits: 'autoscale'
              Parameters: [0×0 Simulink.MaskParameter]
                BaseMask: [0×0 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 does not require the system name (gcb) or the system handle (gcs) to query the mask object for the model mask.

Related Topics