| Simulink® | ![]() |
| On this page… |
|---|
The debugger provides various commands that let you advance a simulation from the method where it is currently suspended (the next method) by various increments (see Stepping Commands). For example, you can advance the simulation
Into or over the next method
Out of the current method
To the top of the simulation loop.
After each advance, the debugger displays information that enables you to determine the point to which the simulation has advanced and the results of advancing the simulation to that point.
For example, in GUI mode, after each step command, the debugger highlights the current method call stack in the Simulation Loop pane. The call stack comprises the next method and the methods that invoked the next method either directly or indirectly. The debugger highlights the call stack by highlighting the names of the methods that make up the call stack in the Simulation Loop pane.

In command-line mode, you can use the where command to display the method call stack. If the next method is a block method, the debugger points the debug pointer at the block corresponding to the method (see Debug Pointer for more information). If the block of the next method to be executed resides in a subsystem, the debugger opens the subsystem and points to the block in the subsystem block diagram.
After executing a block method, the debugger prints any or all of the following block data in the debugger Output panel (in GUI mode) or, if in command line mode, the MATLAB® Command Window:
Un = v
where v is the current value of the block's nth input.
Yn = v
where v is the current value of the block's nth output.
CSTATE = v
where v is the value of the block's continuous state vector.
DSTATE = v
where v is the value of the block's discrete state vector.
The debugger also displays the current time, the ID and name of the next method to be executed, and the name of the block to which the method applies in the MATLAB Command Window. The following example illustrates typical debugger outputs after a step command.

Command-line mode provides the following commands for advancing a simulation incrementally:
| This command... | Advances the simulation... |
|---|---|
| step [in into] | Into the next method, stopping at the first method in the next method or, if the next method does not contain any methods, at the end of the next method |
| step over | To the method that follows the next method, executing all methods invoked directly or indirectly by the next method |
| step out | To the end of the current method, executing any remaining methods invoked by the current method |
| step top | To the first method of the next time step (i.e., the top of the simulation loop) |
| step blockmth | To the next block method to be executed, executing all intervening model- and system-level methods |
| next | Same as step over |
Buttons in the debugger toolbar allow you to access these commands in GUI mode.

Clicking a button has the same effect as entering the corresponding command at the debugger command line.
In GUI mode, the Stop button turns red when the debugger suspends the simulation for any reason. To continue the simulation, click the Start/Continue button. In command-line mode, enter continue to continue the simulation. By default, the debugger runs the simulation to the next breakpoint (see Setting Breakpoints) or to the end of the simulation, whichever comes first.
In animation mode, the Start/Continue button or the continue command advances the simulation method by method, pausing after each method, to the first method of the next major time step. While running the simulation in animation mode, the debugger uses its debug pointer (see Debug Pointer) to indicate on the block diagram which block method is being executed at each step. The moving pointer shows the simulation progress.
Note In animation mode, the debugger does not allow you to set breakpoints and ignores any breakpoints that you set when animating the simulation. |
To enable animation when running the debugger in GUI mode, click the Animation Mode button on the debugger toolbar.

Use the slider on the debugger toolbar to increase or decrease the delay between method invocations, and so slow down or speed up the animation rate. To disable animation mode when running the debugger in GUI mode, toggle the Animation Mode button on the toolbar.
To enable animation when running the debugger in command-line mode, enter the animate command at the command line. The animate command has an optional delay parameter for you to specify the length of the pause between method invocations (1 second by default), and thereby accelerate or slow down the animation. For example, the command
animate 0.5
causes the animation to run at twice its default rate. To disable animation mode when running the debugger in command-line mode, at the command line enter:
animate stop
The run command lets you run a simulation to the end of the simulation, skipping any intervening breakpoints. At the end of the simulation, the debugger returns you to the command line. To continue debugging a model, you must restart the debugger.
Note The GUI mode does not provide a graphical version of the run command. To run the simulation to the end, you must first clear all breakpoints and then click the Start/Continue button. |
The debugger displays a debug pointer on the block diagram whenever it stops the simulation at a method.

The debug pointer is an annotation that indicates the next method to be executed when simulation resumes. It consists of the following elements:
Next method box
Block pointer
Method tile
The next method box appears in the upper-left corner of the block diagram. It specifies the name and ID of the next method to be executed.
The block pointer appears when the next method is a block method. It indicates the block on which the next method operates.
The method tile is a rectangular patch of color that appears when the next method is a block method. The tile overlays a portion of the block on which the next method executes. The color and position of the tile on the block indicate the type of the next block method as follows.

In animation mode, the tiles persist for the length of the current major time step and a number appears in each tile. The number specifies the number of times that the corresponding method has been invoked for the block thus far in the time step.
![]() | Starting a Simulation | Setting Breakpoints | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |