Stateflow User's Guide Previous page   Next Page

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.

  1. In the Stateflow diagram editor, from the Tools menu, select Open Simulation Target.
  1. The Target Options dialog appears.

  1. In the Target Options dialog, select Coder Options.
  1. The Coder Options dialog appears.

  1. Make sure that Enable Debugging/Animation is selected.
  2. Select Close in both the Coder Options and Target Options dialogs to close them and apply the changes.
  3. In the Stateflow diagram editor, from the Tools menu, select Debug.
  1. The Stateflow Debugging window opens.

  1. Select the Chart entry option under the Break Controls border.
  2. Under Animation, select Enabled to enable animation of Stateflow diagrams during simulation.
  3. In the Stateflow Debugging window, select the Start button to start the simulation.
  1. 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:

  1. Select the Step button.
  1. The Step button executes the next execution step and stops.

  1. Continue selecting the Step button and watching the animating Stateflow diagram.
  1. 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.


Previous page  Create the Model and Stateflow Diagram Correcting the Run-Time Error Next page

© 1994-2005 The MathWorks, Inc.