Main Content

Create and Display System Mask Programmatically

You can apply a system mask to a model or a subsystem block diagram. By masking a model, you encapsulate the model to have its own customizable mask parameter dialog box. When you mask a model, the model arguments become the mask parameters. Referencing a masked model results in a better user interface for a model by controlling the model parameters through the mask.

This example shows how to create and display system mask programmatically.

Create System Mask

Use the function Simulink.Mask.Create to create a mask on a subsystem.

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

                             Type: 'sysmask'
                      Description: ''
                             Help: ''
                   Initialization: ''
                   SelfModifiable: 'off'
                     BlockDVGIcon: ''
                          Display: ''
           SaveImageFileWithModel: 'off'
                        IconFrame: 'on'
                       IconOpaque: 'opaque'
             RunInitForIconRedraw: 'analyze'
                       IconRotate: 'none'
                       PortRotate: 'default'
                        IconUnits: 'autoscale'
         SkipCallbackOptimization: 'off'
        SaveCallbackFileWithModel: 'off'
                     CallbackFile: ''
             ParameterConstraints: [0×0 Simulink.Mask.Constraints]
                  PortConstraints: [0×0 Simulink.Mask.PortConstraint]
                       Parameters: [0×0 Simulink.MaskParameter]
                  PortIdentifiers: [0×0 Simulink.Mask.PortIdentifier]
        CrossParameterConstraints: [0×0 Simulink.Mask.CrossParameterConstraints]
             CrossPortConstraints: [0×0 Simulink.Mask.CrossPortConstraint]
    CrossPortParameterConstraints: [0×0 Simulink.Mask.CrossPortParameterConstraint]
                         BaseMask: [0×0 Simulink.Mask]

Display System Mask

Get the mask for the model sysmask and store it in maskObj.

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

                             Type: 'sysmask'
                      Description: ''
                             Help: ''
                   Initialization: ''
                   SelfModifiable: 'off'
                     BlockDVGIcon: ''
                          Display: ''
           SaveImageFileWithModel: 'off'
                        IconFrame: 'on'
                       IconOpaque: 'opaque'
             RunInitForIconRedraw: 'analyze'
                       IconRotate: 'none'
                       PortRotate: 'default'
                        IconUnits: 'autoscale'
         SkipCallbackOptimization: 'off'
        SaveCallbackFileWithModel: 'off'
                     CallbackFile: ''
             ParameterConstraints: [0×0 Simulink.Mask.Constraints]
                  PortConstraints: [0×0 Simulink.Mask.PortConstraint]
                       Parameters: [0×0 Simulink.MaskParameter]
                  PortIdentifiers: [0×0 Simulink.Mask.PortIdentifier]
        CrossParameterConstraints: [0×0 Simulink.Mask.CrossParameterConstraints]
             CrossPortConstraints: [0×0 Simulink.Mask.CrossPortConstraint]
    CrossPortParameterConstraints: [0×0 Simulink.Mask.CrossPortParameterConstraint]
                         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.

See Also

Topics