Mask a Stateflow Block

You can create masks for Stateflow® charts in models. To see a chart already masked, look at shift_logic in the sf_car model that ships with Stateflow.

Create Mask

To create a mask for the Stateflow chart in the model old_sf_carold_sf_car:

  1. Open the model old_sf_carold_sf_car.

  2. From the Simulink® Editor, select the chart shift_logic.

  3. Open the Mask Editor by selecting Diagram-> Mask->Create Mask.

Change the Icon

You can customize the appearance of the block icon by using drawing commands, or loading an image.

  1. On the Icon & Ports pane, in the edit box under Icon Drawing commands type:

    image('shift_logic.svg')
  2. Click Apply.

The Mask Editor loads the image file shift_logic.svg to use as the masked block icon. For more information, see Draw Mask Icon.

Add a Parameter

The chart shift_logic has a parameter TWAIT that is already defined. To add TWAIT as a parameter to the mask:

  1. In the Mask Editor, select the Parameters & Dialog pane.

  2. Double-click the Edit parameter icon.

  3. Next to edit, under Prompt, type

    "Delay before gear change(tick)".

    This text will is the prompt for the new mask parameter in the Mask Parameters dialog box.

  4. Under Name, type "TWAIT".

    This name defines the parameter in the mask. The names ties it to the underlying block parameter with the same name, TWAIT.

  5. Click Apply.

  6. Click OK.

For more information, see Parameters & Dialog Pane.

View the New Mask

After creating a mask, the new icon for the shift_logic chart appears in the Simulink canvas. The name of the block has not changed.

If you double-click the icon, the Mask Parameters dialog box opens. This dialog box has the prompt for the parameter TWAIT. The value in the edit box is assigned to the parameter TWAIT during simulation.

To see the logic in the shift_logic chart, click the Look inside mask badge on the chart.

Edit the Mask

You can edit a mask by selecting Diagram > Mask > Edit Mask.

Was this topic helpful?