sldebug - Start simulation debugging session for Simulink model - MATLAB (original) (raw)

Main Content

Start simulation debugging session for Simulink model

Syntax

Description

sldebug([mdl](#mw%5Fd3bdee8f-27d6-4fdf-a4c8-6d1597880010)) starts a programmatic simulation debugging session for the model specified by mdl. The simulation starts and pauses just before the initialization phase.

When you start a programmatic simulation debugging session, the MATLAB® command prompt becomes the sldebug command prompt. Instead of >>, you see (sldebug @0): >>. To control the debugging session, enter commands in the MATLAB Command Window at the sldebug command prompt using the Simulink® debugging programmatic interface.

During a programmatic simulation debugging session, you can use the debugging functions to:

To end a programmatic simulation debugging session, use the stop function.

example

Examples

collapse all

Start and then stop a simulation debugging session for the model vdp.

Open the model vdp.

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

Use the sldebug function to start the simulation debugging session for the model.

%----------------------------------------------------------------% [TM = 0 ] simulate(vdp)

The MATLAB command prompt changes from >> to (sldebug @0): >> to indicate that a debug simulation is in progress and that the Simulink debugging programmatic interface is available.

Use the step command to step the simulation to the start of the next major time step.

%----------------------------------------------------------------% [TM = 0 ] vdp.Outputs.Major

You can continue using the step command to progress the simulation and observe the results in the Scope block.

Use the stop function to stop the debug simulation.

%----------------------------------------------------------------% % Simulation stopped

Input Arguments

collapse all

Name of model to debug, specified as a string or a character vector.

Example: sldebug("vdp") starts a simulation debugging session for the model vdp.

Data Types: char | string

Tips

As an alternative to programmatic debugging, you can debug and analyze models in the Simulink Editor using similar functionality available in the Simulink Toolstrip. Using the Debug tab, you can:

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 thestop command, are available for use in the MATLAB Command Window.

When you start a simulation debugging session interactively, the simulation pauses just before executing the first block output method.

Version History

Introduced in R2006a