Debugger Actions

In debug mode, you can take actions to progress the simulation and modify blocks during pauses.


You can use several buttons in the debugger dialog box to progress a simulation. When you first open the debugger, the following options are available:
  • START: The simulation runs until all pause conditions are satisfied. When a pause condition is triggered, the simulation pauses and the debugger dialog box is reactivated.
  • STEP: The simulation runs and steps at every call. Pause conditions are ignored, except for whether to include try mode calls.
  • FINISH: The simulation runs without pausing until the end, unless an error occurs.

When the simulation is paused, the START button is renamed CONTINUE, which performs the same action. The QUIT button becomes active and can be used to end the simulation and exit debug mode. If you quit debug mode, termination calls are made to the blocks to cleanly terminate the simulation and close any files opened by a block.

When the simulation ends, the RESTART button lets you restart the simulation under the same conditions.

OML commands

When the simulation is paused, the OML commands to execute text box is activated. You can enter OML expressions in this text box to define variables for use in subsequent pauses. Variables defined here are persistent in the debugger workspace.
Note: Persistent variables are particularly useful when the debugger is run in non-interactive mode and OML instructions are executed automatically during every pause. For more information, see Non-Interactive Mode.

The results of OML commands are shown in the large text box on the right side of the dialog box.

You can use OML commands to redefine variables, in particular outputs, xd, z, and oz, to update the values of the associated block signals under actions and in phases where such an update is meaningful. An update is meaningful if it is consistent with timing and the flag value. For example, when flag = 1 (output update), it is not meaningful to change the state of the block. When entering a block, changing the output is not meaningful because the block does not read its outputs, so changing an output when entering the block is ignored. The output can be changed when leaving the block.

The OML commands can contain any of the variables in the table below. The variables that can be used are shown at the bottom of the dialog box.

Table 1. OML variables available for debugging
Variable Description
block_name Block name (string)
t Current simulation time (double)
inputs Input values (cell | mat)
outputs Output values (cell | mat)
nevprt Block activation code (double)
x Continuous-time state (vector)
xd Derivative of the continuous-time state (vector)
mode Block modes (vector)
zcross Zero-crossing surfaces (vector)
z Discrete-time block state (vector)
oz Discrete-time object states (cell | mat)
rpar Block parameter (vector)
opar Object parameters (cell | mat | scalar | string)
trymode True if call is made in try mode, otherwise false
block OML object corresponding to the block structure
flag Indicates the action associated with the call
prepost 0 or 1 depending whether in pre- or post-call phase
Note: To see an element of a block that is not in the list of available variables, you must use the appropriate API. For example, to know if the block is called in a phase where the block modes are fixed, use the following command:
The following example uses the BoocWen damper system demo model. The pause conditions are:
  • List of blocks: SuperBlock/Integral
  • Included action: Derivative update (flag 0)
  • Include try mode calls
  • Included phases: Only post call
To show the values of the block input, state, and state derivative, enter the following into the OML commands box:

Click START to enter the first pause and see the results to the right. The initial values are shown at t = 0. To skip other similar calls until a certain time, set the stopping condition to a later time:

t > 0.05

Click CONTINUE to see the values at that time.