Animate Stateflow Charts with Simulink External Mode

The Simulink® Real-Time™ software supports the animation of Stateflow® charts in your model to provide visual confirmation that your chart behaves as expected.

You must be familiar with the use of Stateflow animation. For more information on Stateflow animation, see Animate Stateflow Charts (Stateflow).

You must have already set Stateflow states as test points in model ex_slrt_sf_car (matlab: open_system(docpath(fullfile(docroot, 'toolbox', 'xpc', 'examples', 'ex_slrt_sf_car')))). If you have not, see Configure Stateflow States as Test Points.

  1. In the Simulink Editor, select Simulation > Mode > External.

  2. Select Code > External Mode Control Panel.

  3. Select Signal & Triggering.

  4. In the Trigger section of the External Signal & Triggering window:

    • Set Mode to normal.

    • In the Duration box, enter 5.

    • Select the Arm when connecting to target check box.

  5. Click Apply.

  6. Select Simulation > Model Configuration Parameters.

  7. Navigate to the Simulink Real-Time Options node.

  8. Select the Enable Stateflow animation check box.

  9. Click Apply.

  10. Build and download the model to the target computer.

  11. On the toolbar, click the Connect To Target button .

    The current Simulink model parameters are downloaded from the development computer to the real-time application.

  12. To start the simulation, click the Run button  on the toolbar.

    The simulation begins to run. You can observe the animation by opening the Stateflow Editor for your model.

  13. To stop the simulation, click the Stop button  on the toolbar.


Enabling the animation of Stateflow charts also displays additional Stateflow information. The Stateflow software requires this information to animate charts. You can disregard this information.

Related Topics

Was this topic helpful?