Using Stateflow     Search    Help Desk 

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:

   1.
Ensure that the Stateflow diagram and the Scope block are open.
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.
   2.
Select Open Simulation Target from the graphics editor Tools menu.
The Simulation Target Builder dialog box appears.
   3.
Select Coder Options on the Simulation Target Builder dialog box.
The Simulation Coder Options dialog box appears.
   4.
Ensure that the checkbox to Enable Debugging/Animation is checked. Click on the OK button to apply the change. Close the Simulation Coder Options and the Simulation Target Builder dialog boxes.
   5.
Select Debug from the graphics editor Tools menu. Ensure that the Enabled radio button under Animation is checked to enable Stateflow diagram animation. Click on the Close button to apply the change and close the window.
   6.
Choose Start from the graphics editor Simulation menu to start a simulation of the model.
By default the S-function is the simulation target for any Stateflow blocks. Informational and error messages related to the S-function code generation for Stateflow blocks are displayed in the MATLAB command window. Once the simulation is started and the target is built, the graphics editor becomes read-only (frozen).
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.
   7.
Choose Stop from the graphics editor Simulation menu to stop a simulation. Once the simulation is stopped the graphics editor becomes writeable (unfrozen).


[ Previous | Help Desk | Next ]