Using Simulink | ![]() ![]() |
Displaying Information About the Simulation
The Simulink debugger provides a set of commands that allow you to display block states, block inputs and outputs, and other information while running a model.
Displaying Block I/O
The debugger allows you to display block I/O by selecting the appropriate buttons on the debugger toolbar
or by entering the appropriate debugger command.
Command |
Displays a Block's I/O |
probe |
Immediately |
disp |
At every breakpoint |
trace |
Whenever the block executes |
Displaying I/O of Selected Block
To display the I/O of a block, select the block and clickin GUI mode or enter the
probe
command in command-line mode.
The debugger prints the current inputs, outputs, and states of the selected block in the debugger output pane (GUI mode) or the MATLAB command window.
The probe
command comes in handy 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 block by block. Each time you step the model, 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. Similarly, suppose you are using the next
command to step through a model by time steps. The next
command does not display block I/O. However, if you need to examine a block's I/O after entering a next
command, you can do so using the probe
command.
Displaying Block I/O Automatically at Breakpoints
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's 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
.
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. So, you do not need to use the disp
command if you are interested in watching only the I/O of the current block.
Watching Block I/O
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 watch check box for the block in 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's 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.
![]() | Setting Breakpoints at Time Steps | Displaying Algebraic Loop Information | ![]() |