Main Content


Stop simulation debugging session




    stop stops a simulation debugging session.

    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.

    To stop a simulation using a logical signal in your model, use the Stop Simulation block.

    To stop a simulation that was started using the Run button or by using the set_param function to specify a simulation command, click the Stop button or use the set_param function to specify the stop simulation command.



    collapse all

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

    Open the model vdp.


    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.

    step top
    [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


    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 in R2006a

    expand all