Main Content


Configure simulation debugging session to display information when entering and exiting methods


etrace lvl configures method tracing for certain methods according to the value you specify for lvl. You can configure a simulation debugging session to trace:

  • No methods

  • Model methods

  • Model and system methods

  • Model, block, and system methods

The simulation debugging session displays information each time the simulation enters or exits a traced method. The information displayed includes the current simulation time, whether the simulation entered or exited the method, the method name, the method ID, and the name of the model, system, or block to which the method belongs.

  • When you start the simulation debugging session programmatically, the information is displayed in the MATLAB® Command Window.

  • When you start the simulation debugging session using the Simulink® Editor, the information is displayed in the Diagnostic Viewer.

You can use this function in a simulation debugging session started:

  • Interactively, using the Simulink Toolstrip

  • Programmatically, using the sldebug function

  • Programmatically, using the sim function with the 'debug' name-value argument


This function is available only for simulation debugging sessions started programmatically and for interactive simulation debugging sessions while paused within a time step.

Input Arguments

collapse all

Methods to trace, specified as one of these options:

  • 0 — No methods

  • 1 — Model methods

  • 2 — Model and system methods

  • 3 — Model, system, and block methods


To start a simulation debugging session interactively, add one or more breakpoints to your model, and in the Breakpoints List, check that Pause within time step is selected. When the simulation pauses on a breakpoint, some of the programmatic debugging commands, such as the stop command, are available for use in the MATLAB Command Window.

Version History

Introduced before R2006a

expand all