Display Information About the Simulation

Display Block I/O

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 ( ) and Display Block I/O ( ) correspond, respectively, to trace gcb and probe gcb. The probe and disp commands do not have a one-to-one correspondence with the debugger toolbar buttons.

Displaying I/O of a Selected Block

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.

CommandDescription

probe

Enter or exit probe mode. 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.

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 by entering its block index 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, 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.

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 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.

Display Algebraic Loop Information

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

Display System States

The states debug command lists the current values of the system states in the MATLAB Command Window. For example, the following sequence of commands shows the states of the bouncing ball example (sldemo_bounce) after its first, second, and third time steps. However, before entering the debugger, open the Configuration Parameters dialog box, clear the Block reduction check box on the Optimization pane, and clear the Signal storage reuse check box on the Optimization > Signals and Parameters pane.

 sldebug sldemo_bounce 
%----------------------------------------------------------------%
[TM = 0                      ] simulate(sldemo_bounce)
(sldebug @0): >> step top
%----------------------------------------------------------------%
[TM = 0                      ] sldemo_bounce.Outputs.Major
(sldebug @16): >> next
%----------------------------------------------------------------%
[TM = 0                      ] sldemo_bounce.Update
(sldebug @23): >> states

Continuous States:
Idx  Value                    (system:block:element  Name   'BlockName')
  0  10                       (0:4:0  CSTATE  'sldemo_bounce/Second-Order  Integrator')
  1. 15                       (0:4:1)

(sldebug @23): >> next
%----------------------------------------------------------------%
[Tm = 0                      ] solverPhase
(sldebug @26): >> states

Continuous States:
Idx  Value                    (system:block:element  Name   'BlockName')
  0  10                       (0:4:0  CSTATE  'sldemo_bounce/Second-Order  Integrator')
  1. 15                       (0:4:1)

(sldebug @26): >> next
%----------------------------------------------------------------%
[TM = 0.01                   ] sldemo_bounce.Outputs.Major
(sldebug @16): >> states

Continuous States:
Idx  Value                    (system:block:element  Name   'BlockName')
  0  10.1495095               (0:4:0  CSTATE  'sldemo_bounce/Second-Order  Integrator')
  1. 14.9019                  (0:4:1)

Display Solver Information

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.

Was this topic helpful?