Main Content

emode

Switch between accelerator and normal mode during simulation debugging session

Syntax

Description

emode switches the simulation mode between accelerator mode and normal mode during a simulation debugging session.

The Simulink® debugging programmatic interface supports only normal mode and accelerator mode simulations. Rapid accelerator mode is not supported.

To switch between accelerator mode and normal mode, you must start the simulation debugging session with the model in accelerator mode. Before starting the simulation debugging session, in the Simulink Toolstrip, on the Simulation tab, in the Simulate section, select Accelerator from the drop-down list.

Starting a simulation debugging session in accelerator mode can speed up a simulation debugging session. For example, if you know you need to investigate the simulation after a certain simulation time, you can start the simulation debugging session in accelerator mode, specify a time breakpoint, and continue. The simulation runs faster in accelerator mode than it would in normal mode to reach the time breakpoint. Then, for access to complete debugging capabilities, you can change to normal mode.

You must switch to normal mode execution to step the simulation block by block and to use these functions:

Note

This function is supported only for simulation debugging sessions started programmatically using the sldebug function or using the sim function with the 'debug' name-value argument.

example

Examples

collapse all

For complex models and long simulations, accelerator mode can decrease the time required to debug a simulation. This example shows how to switch between simulation modes for a simulation of the model vdp.

Open the model vdp.

openExample("simulink_general/VanDerPolOscillatorExample",...
    supportingFile="vdp")

To use accelerator mode during a simulation debugging session, you must start the simulation debugging session with the model configured to simulate in accelerator mode. In the Simulink Toolstrip, on the Simulation tab, in the Simulate section, select Accelerator from the simulation drop-down list.

Start a simulation debugging session for the model vdp using the sldebug function. The MATLAB® command prompt (>>) becomes the Simulink debugger prompt ((sldebug @0): >> ).

sldebug vdp
(sldebug @0): >> 

Use the tbreak function to set a breakpoint for a simulation time of 5 seconds.

tbreak 5
Time break point                           : enabled (t>=5.0)

Use the continue function to progress the simulation debugging session to the time breakpoint. This portion of the simulation runs in accelerator mode.

continue
Interrupting model execution at time break point (tbreak 5)
%----------------------------------------------------------------%
[Tm = 5.0073507114851168     ] vdp.Outputs.Minor

Only a subset of the debugging capabilities are available while the model runs in accelerator mode. To use the full Simulink debugging programmatic interface to debug the model at this point of interest, use the emode function to switch to normal mode.

emode
Execution Mode                             : Normal
Normal execution mode. All break points are enabled.

Use the step function to progress the simulation. This portion of the simulation debugging session runs using normal mode.

step top
%----------------------------------------------------------------%
[TM = 5.051795155929562      ] vdp.Outputs.Major

After investigating this point of interest, you can:

  • Continue the simulation debugging session in normal mode.

  • Set a breakpoint for another point of interest, use the emode function to switch back to accelerator mode, and use the continue function to progress the simulation to the point of interest.

  • Use the stop function to end the simulation debugging session.

Version History

Introduced before R2006a