Use Simulation Stepper
Simulation Stepper Access
You run Simulation Stepper and access the settings from the Simulink® Toolstrip.
Click the Configure simulation stepping button to open the Simulation Stepping Options dialog box.
Use the dialog box to enable stepping back through a simulation. When stepping back is enabled, after you start the simulation, you can use the Step Back button to step back.
If you clear the Enable previous stepping check box, the software clears the stored snapshot cache.
Simulation Stepper Pause Status
The status bar at the bottom of the Simulink Editor displays the simulation time of the last completed simulation step. While a simulation is running, the editor updates the time display to indicate the simulation progress. This display is approximate because the status bar updates only at every major time step and not at every simulation time step. When you pause a simulation, the status bar display time catches up to the actual time of the last completed step.
The value (the time of the last completed step) that is displayed on the status bar is not always the same as the time of the solver. This happens because different solvers use different ways to propagate the simulation time in a single iteration of the simulation loop. Simulation Stepper pauses at a single position within the simulation loop. Some solvers perform their time advance before Simulation Stepper pauses. However, other solvers perform their time advance after Simulation Stepper pauses, and the time advance then becomes part of the next step. As a result, for continuous and discrete solvers, the solver time is always one major step ahead of the time of the last model output.
When this condition occurs, and the simulation is paused, the status bar time displays an asterisk. The asterisk indicates that the solver in this simulation has already advanced past the displayed time (which is the time of the last completed simulation step).
While using Simulation Stepper, when the simulation is paused, you can change tunable parameters, including some solver settings. However, changes to the solver step size take effect when the solver advances the simulation time. For some solvers, this occurs after the next simulation step is taken.
Simulation Stepper takes into account the size of a movement (Move back/forward by) and the frequency of saving steps (Interval between stored back steps). If you specify a frequency that is larger than the step size, Simulation Stepper first steps back to the last saved step and then simulates forward until the total step count difference reaches the size of the desired movement. Simulation Stepper applies values for tunable parameters when simulating forward. For this reason, if you change any tunable parameter before stepping back, the resulting simulation output might not match the previous simulation output at that step before the parameter change. This can cause unexpected results when stepping forward from the snapshot to the chosen time step.
For example, assume a snapshot save frequency of three and a step size of one. The stepper first steps back to the last saved step, up to three steps, and then simulates forward until the total step count difference reaches one. If you change tunable parameters before stepping back, the resulting simulation output might not match the previous simulation output at that step.
When using Simulation Stepper and the Model block, the referenced model shares the stepping options of the top model throughout a simulation. As a result, changing Simulation Stepper settings for the referenced model during simulation changes the Simulation Stepper settings of the top model. When the simulation ends, the settings of the referenced model revert to the original values; the Stepper settings of the top model stay at the changed settings.
When the model is not simulating, the top model and referenced model retain their own independent stepping options.
When the model is simulating and you change a referenced model stepping option, the top model stepping option changes to the same value.
When the model is simulating and you change a top model stepping option, the referenced model stepping option changes to the same value.
When the model stops simulating, the referenced model stepping options revert to how they were set before simulation started; the top model keeps the values set during simulation.
Simulation Stepper and Interval Logging
When you change the logging interval of a simulation before rolling back, Simulink does not log data for time steps that were outside the original logging interval until the first forward step after a rollback operation. For more information, see Logging intervals.
Simulation Stepper and Stateflow Debugger
When you debug a Stateflow® chart (for example, when the simulation stops at a Stateflow breakpoint), Simulation Stepper adds buttons to control the Stateflow debugging session. When the Stateflow debugging session ends, the Simulation Stepper interface returns to the default. For more information about controlling the Stateflow debugger using the Simulink Toolstrip, see Control Chart Execution After a Breakpoint (Stateflow).