| Simulink® | ![]() |
| On this page… |
|---|
The debugger allows you to display block I/O by clicking the appropriate buttons on the debugger toolbar

or by entering the appropriate debugger command.
| This command... | Displays a Blocks I/O... |
|---|---|
| probe | Immediately |
| disp | At every breakpoint any time execution stops |
| trace | Whenever the block executes |
Note
The two debugger toolbar buttons, Watch Block I/O (
|
To display the I/O of a block, select the block and click
in GUI mode or enter
the probe command in command-line mode. In the
following table, the probe gcb command has a corresponding
toolbar button. The other commands do not.
| Command | Description |
|---|---|
probe | Enter or exit probe mode. In probe mode, the debugger displays the current inputs and outputs of any block that you select in the model's block diagram. Typing any command causes the debugger to exit probe mode. |
probe gcb | Display I/O of selected block. Same as
|
probe s:b | Print the I/O of the block specified by system number s and block number b. |
The debugger prints the current inputs, outputs, and states of the selected block in the debugger Outputs pane (GUI mode) or the Command Window of the MATLAB® product.
The probe command is useful when you need to examine the I/O of a block whose I/O is not otherwise displayed. For example, suppose you are using the step command to run a model method by method. Each time you step the simulation, the debugger displays the inputs and outputs of the current block. The probe command lets you examine the I/O of other blocks as well.
The disp command causes the debugger to display a specified block's inputs and outputs whenever it halts the simulation. You can specify a block either by entering its block index or by selecting it in the block diagram and entering gcb as the disp command argument. You can remove any block from the debugger list of display points, using the undisp command. For example, to remove block 0:0, either select the block in the model diagram and enter undisp gcb or simply enter undisp 0:0.
Note Automatic display of block I/O at breakpoints is not available in the debugger GUI mode. |
The disp command is useful when you need to monitor the I/O of a specific block or set of blocks as you step through a simulation. Using the disp command, you can specify the blocks you want to monitor and the debugger will then redisplay the I/O of those blocks on every step. Note that the debugger always displays the I/O of the current block when you step through a model block by block, using the step command. You do not need to use the disp command if you are interested in watching only the I/O of the current block.
To watch a block, select the block and click
in the debugger toolbar
or enter the trace command. In GUI mode, if a breakpoint
exists on the block, you can set a watch on it as well by selecting
the check box for the block in the watch column
of
the Break/Display points pane. In
command-line mode, you can also specify the block by specifying its
block index in the trace command. You can remove
a block from the debugger list
of trace points using the untrace command.
The debugger displays a watched block's I/O whenever the block executes. Watching a block allows you obtain a complete record of the block's I/O without having to stop the simulation.
The atrace command causes the debugger to display information about a model's algebraic loops (see Algebraic Loops) each time they are solved. The command takes a single argument that specifies the amount of information to display.
| This command... | Displays for each algebraic loop... |
|---|---|
| atrace 0 | No information |
| atrace 1 | The loop variable solution, the number of iterations required to solve the loop, and the estimated solution error |
| atrace 2 | Same as level 1 |
| atrace 3 | Level 2 plus the Jacobian matrix used to solve the loop |
| atrace 4 | Level 3 plus intermediate solutions of the loop variable |
The states debug command lists the current values of the system's states in the MATLAB product Command Window. For example, the following sequence of commands shows the states of the bouncing ball demo (bounce) after its first and second time steps.
sldebug bounce [Tm=0 ] **Start** of system 'bounce' outputs (sldebug @0:0 'bounce/Position'): states Continuous state vector (value,index,name): 10 0 (0:0 'bounce/Position') 15 1 (0:5 'bounce/Velocity') (sldebug @0:0 'bounce/Position'): next [Tm=0.01 ] **Start** of system 'bounce' outputs (sldebug @0:0 'bounce/Position'): states Continuous state vector (value,index,name): 10.1495095 0 (0:0 'bounce/Position') 14.9019 1 (0:5 'bounce/Velocity')
The strace command allows you to pinpoint problems in solving a models differential equations that can slow down simulation performance. Executing this command causes the debugger to display solver-related information at the command line of the MATLAB product when you run or step through a simulation. The information includes the sizes of the steps taken by the solver, the estimated integration error resulting from the step size, whether a step size succeeded (i.e., met the accuracy requirements that the model specifies), the times at which solver resets occur, etc. If you are concerned about the time required to simulate your model, this information can help you to decide whether the solver you have chosen is the culprit and hence whether choosing another solver might shorten the time required to solve the model.
![]() | Setting Breakpoints | Displaying Information About the Model | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |