Run a Simulation
These steps show how to run a simulation:
On_offStateflow block to display the Stateflow diagram.
sfunis 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. This is displayed as "Ready (ICED)" where the term "ICED" is an internal Stateflow designation.
The input from the Sine Wave 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
|Note Running a simulation might require setting up the tools used to build Stateflow targets. See Setting Up the Target Compiler for more information.|
Where Stateflow Generates Code for Simulation
When you simulate a Simulink model containing Stateflow charts (as you did in the previous section), Stateflow generates a Simulink S-function (
sfun) target that enables Simulink to simulate the Stateflow blocks. The
sfun target can be used only with Simulink.
Before generating code, Stateflow creates a directory called
sfprj in the current MATLAB directory if the directory does not already exist. Stateflow uses the
sfprj directory during code generation to store generated files. See the section Generated Files.
Do not confuse the |
If you have the Stateflow Coder, you can generate stand-alone code suitable for a particular processor. See Building a Target for more information on code generation.
|Parse the Stateflow Diagram||Debug the Model During Simulation|