This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

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.

  2. Click View > Model Explorer > Model Workspace. The Model Explorer dialog box opens.

  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.

Step 2: Create Model Mask

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

    Alternatively, in Simulink click Diagram > Mask > Create Model Mask or right-click the model, and in the context menu, click Mask > Create Model 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.

    Note

    The Mask Editor dialog box for model mask does not contain the Initialization tab. Initialization code can alter the model and other model reference blocks, and thus affect the simulation results.

  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 model mask.

    • Model 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 Model Mask Parameters

  1. To view the mask parameter dialog box, click Diagram > Mask > Model Mask Parameters.

    Tip

    To edit the model mask parameters, click Diagram > Mask > Edit Model 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.

  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.

  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, right-click 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.

See Also

| |