Main Content

Create and Reference a Masked Model

This example shows how to mask a model and reference the masked model from the Model block.

Step 1: Define Mask Arguments

  1. Open the model in Simulink®. For example, consider a simple model containing two Gain blocks, a Constant block, and a Display block.

    system mask gain block

  2. On the Modeling tab, under Design, click Model Explorer > Model Workspace.

  3. Click Add > MATLAB Variable. A variable of data type double is created in the Model Workspace.

  4. Select the Argument check box corresponding to the MATLAB® variables to make it a model argument, for example, k and l.

    system mask model explorer

Step 2: Create Model Mask

  1. In the Model Workspace pane, click Create System Mask.

    Alternatively, in Simulink, on the Modeling tab, under Component, click Create Model Mask, or right-click the model, and select Mask > Create System Mask.

    The Mask Editor dialog box opens.

  2. Click the Parameters & Dialog tab. The model arguments that you select in Model Explorer appear in the Mask Editor dialog box as mask parameters.

    Tip

    Ensure that the model arguments you have selected in the Model Explorer dialog box are added as block parameters in the model. For example, the arguments k and l are passed to Gain A and Gain B blocks, respectively.

    system mask editor

  3. Select a mask parameter (k or l) on the Dialog box pane and edit its properties in the Property editor, as required. For example, you can change the prompt name, parameter type, value, or orientation.

    By default, the Edit parameter type is assigned to a model mask parameter. You can change the parameter type by editing the Type property in the Property editor section.

    Note

    • Simulink supports only the Edit, Slider, Dial, and Spinbox parameter types for system mask.

    • Simulink does not support non tunable parameters for system mask.

    • System mask supports all types of display and action controls.

  4. Click OK. The Simulink model is now masked and contains the model arguments as the mask parameter.

  5. Save the model.

Step 3: View System Mask Parameters

  1. To view the mask parameter dialog box, on the Component tab, under System Mask, click Mask Parameters.

    model mask parameters

    Tip

    To edit the system mask parameters, on the Component tab, under System Mask, click Edit System Mask.

  2. Save the masked model.

Step 4: Reference Masked Model

  1. Open a blank model in Simulink and add the Model block from the library.

  2. To reference the masked model from the Model block, specify the name of the masked model as the Model name in the Block parameter dialog box.

    referencing model

  3. To view the parameter dialog box of the referenced model, right-click the Model block, and in the context menu, click Mask > Mask Parameters. Alternatively, double-click the Model block.

  4. Type 2 and 3 as the parameter values for k and l respectively.

    system mask dialog parameters

  5. Click OK.

  6. Simulate the model and view the result on the display block.

  7. To view the referenced model from the Model block, click Mask > Look Under Mask.

  8. To view the mask, select the Model block and click Mask > View Mask. The Mask Editor dialog box opens. The Mask Editor dialog box displays the uneditable mask parameters of the referenced model.

    system mask editor

Related Topics