| Stateflow User's Guide |
 |
Debugging the Stateflow Diagram
You create an example model with a Stateflow diagram that needs debugging in Create the Model and Stateflow Diagram. Use the steps that follow to debug the Stateflow diagram in this model.
- In the Stateflow diagram editor, from the Tools menu, select Open Simulation Target.
- The Target Options dialog appears.
- In the Target Options dialog, select Coder Options.
- The Coder Options dialog appears.
- Make sure that Enable Debugging/Animation is selected.
- Select Close in both the Coder Options and Target Options dialogs to close them and apply the changes.
- In the Stateflow diagram editor, from the Tools menu, select Debug.
- The Stateflow Debugging window opens.
- Select the Chart entry option under the Break Controls border.
- Under Animation, select Enabled to enable animation of Stateflow diagrams during simulation.
- In the Stateflow Debugging window, select the Start button to start the simulation.
- Informational messages are displayed in the MATLAB Command Window. The graphics editor toolbar and menus change appearance to indicate a read-only interface. The Stateflow diagram is parsed, the code is generated, and the target is built.
Because you specified a breakpoint on chart entry, the execution stops at that point and the Debugger display status indicates the following:
- Select the Step button.
- The Step button executes the next execution step and stops.
- Continue selecting the Step button and watching the animating Stateflow diagram.
- After each step, watch the Stateflow diagram animation and the Debugger status area to see the sequence of execution.
Single-stepping shows that the Stateflow diagram does not exhibit the desired behavior. The transitions from the First to the Second to the Third state inside the state Power_on are not occurring because the transition from Power_on to Power_off takes priority. The output display of code coverage also confirms this observation.
| Create the Model and Stateflow Diagram | | Correcting the Run-Time Error |  |
© 1994-2005 The MathWorks, Inc.