Documentation

Create a Simple Mask

You can mask a block interactively by using the Mask Editor or mask it programmatically. This example describes how to mask a block by using the Mask Editor. To mask a block programmatically, see Control Masks Programmatically.

For masking examples, see Simulink Masking Examples.

Step 1: Open Mask Editor

  1. Open the model in which you want to mask a block. For example, open subsystem_example.

    This model contains a Subsystem block that models the equation for a line: y = mx + b.

  2. Right-click the Subsystem block and select Mask > Create Mask.

Step 2: Define the Mask

The Mask Editor contains four tabs that enable you to define the block mask and customize the dialog box for the mask.

For detailed information on each pane, see Mask Editor Overview.

Icon & Ports Tab

Use this tab to create an icon for the block mask. You can use the Options pane on the left to specify icon properties and icon visibility.

Add an image to the block mask.

  1. In the Block frame drop-down box, select Visible.

  2. In the Icon transparency drop-down box, select Opaque.

  3. In the Icon units drop-down box, select Autoscale.

  4. To restrict the icon rotation, select Fixed from the Icon rotation list.

  5. In the Icon drawing commands text box, type plot(y,x).

    For more information on drawing command syntax, see Icon drawing commands.

  6. To save the changes, click Apply. To preview the block mask icon without exiting the Mask Editor, click Preview

You can create static or dynamic block mask icons. For more information, see Draw Mask Icon and slexMaskDisplayAndInitializationExample.

Parameters & Dialog Tab

Use this tab to add controls like parameters, displays, and action items to the mask dialog box.

To add Edit boxes to the block mask.

  1. In the left pane, under Parameter, click Edit twice to add two new rows in the Dialog box pane.

  2. Type Slope and Intercept in the Prompt and Name columns, respectively. The value that you enter in Prompt column appears on the mask dialog box. The value you enter in Name column is the mask parameter name. The mask parameter name must be a valid MATLAB® name.

  3. In the right pane, under Property editor, provide values in the Properties, Dialog, and Layout sections.

  4. Click Apply.

  5. To preview the mask dialog box without exiting the Mask Editor, click Preview.

Initialization Tab

Use this pane to specify MATLAB code to control the mask parameters. You can add conditions for the user specified values, provide a predefined value for a mask parameter, and so on.

Consider the equation y = mx + b. To allow positive value for m, you can add MATLAB code in the initialization pane to specify the acceptable range for m as greater than zero.

Documentation Tab

Use this tab to add a name, description, and additional information for the mask.

The Documentation tab contains these fields:

  1. Type: You can add a name for the block mask in this box. The mask name appears on top of the mask dialog box. You cannot add new lines.

  2. Description: You can add a description for the block mask in this box. By default, the description is displayed below the mask name, and it can contain new lines and spaces.

  3. Help. You can add additional information for the block mask in this box. You click Help on the mask dialog box, this information is displayed. You can use plain text, HTML and graphics, URLs, and web or eval commands to add information in the Help field.

    After you have added information in the Mask Editor, click Apply or OK.

    The block is now masked.

Step 3: Operate on Mask

  1. You can preview the mask and choose to unmask the block or edit the block mask.

  2. Double-click the masked block.

    The mask dialog box appears.

  3. Type values in the Slope and Intercept boxes of the mask dialog box. To view the output, simulate the model.

  4. Click OK.

  5. To edit the mask definition, right-click the block and select Mask > Edit Mask. For more information, see Manage Existing Masks.

  6. Right-click the masked block and select Mask > Look Under Mask to view:

    • The blocks inside the masked subsystem

    • The built-in block dialog box of a masked block

    • The base mask dialog box of a linked masked block

See Also

| |

Was this topic helpful?