Stateflow | ![]() ![]() |
Running a Simulation
Note Running a simulation may require setting up the tools used to build Stateflow targets. See Setting Up Target Build Tools for more information. |
These steps show how to run a simulation:
Double-click on the On_off
Stateflow block to display the Stateflow diagram.
Double-click on the Scope block to display the output of the Sine wave.
The Simulation Target Builder dialog box appears.
The Simulation Coder Options dialog box appears.
By default the S-function is the simulation target for any Stateflow blocks. Stateflow displays code generation status messages in the MATLAB command window. Before starting the simulation, Stateflow temporarily sets the model to read-only to prevent accidental modification while the simulation is running.
The input from the Sine block is defined as the Input from Simulink event
Switch
. When the simulation starts the Stateflow diagram is animated
reflecting the state changes triggered by the input sine wave. Each input
event of Switch
toggles the model between the Power_off
and Power_on
state.
![]() | Parsing the Stateflow Diagram | Debugging | ![]() |