These topics explain how Simulation Stepper steps through a simulation.
When you set up Simulation Stepper, you specify:
The number of time steps where Stepper creates ‘snapshots’
The number of steps to skip between snapshots
The total number of snapshots stored
A simulation snapshot contains simulation state (SimState) and information related to logged data and visualization blocks. Simulation Stepper stores simulation states in snapshots at the specified interval of time steps when it steps forward through a simulation.
It is important to understand the difference between a Simulation Stepper step and a simulation time step. A simulation time step is the fixed amount of time by which the simulation advances. A Simulation Stepper step is where Simulation Stepper creates a snapshot. Each step (that Simulation Stepper takes) consists of one or more simulation time steps (that you specify).
When you step back through a simulation, the software uses simulation snapshots, stored as SimStates, to display previous states of the simulation. The model does not simulate in reverse when stepping back. Therefore, to enable the step back capability, you must first simulate the model or step it forward to save snapshots.
Keep in mind that snapshots for stepping back are available only during a single simulation. The Simulation Stepper does not save the steps from one simulation to the next.
A simulation snapshot captures all the information required to continue a simulation from that point. When you set up simulation stepping, you specify:
The maximum number of snapshots to capture while simulating forward. The greater the number, the more memory the simulation uses and the longer the simulation takes to run.
The number of time steps to skip between snapshots. This setting enables you to save snapshots of simulation state when stepping forward at periodic intervals, such as every three steps. This interval is independent of the number of forward or backward time steps taken. Because taking simulation snapshots affects simulation speed, saving snapshots less frequently can improve simulation speed.
The figure shows how you can step through a simulation depending on how you set the parameters in the Simulation Stepping Options dialog box. Because you can change the stepping parameters as you step through the simulation, you can step through a simulation as shown in this figure: sometimes by single steps and sometimes by two or more steps.
In the figure, the interval for snapshot captures is three.
This next figure shows the advantage of changing the stepping options while stepping forward. At the fourth step, the interval between stored steps changed the snapshot steps from three to one. This enables you to capture more snapshots around a simulation time of interest.
The next figure shows how the snapshot settings of Simulation Stepper can change what happens when stepping back. Suppose that the interval between snapshots is set to three, and starting at state six, the stepper Move back/forward by setting is set to one. The stepper first restores the simulation state to the last saved snapshot (state three), and then simulates two major times steps to arrive at the desired state (state five).
Thus, when you step back to a particular time step in a simulation, Simulation Stepper restores the last saved snapshot before that time step. Then, it steps forward to the time step you specify. This capability is helpful for memory usage and simulation performance.
Simulation Stepper and Simulink® Debugger both enable you to start, stop, and step through a model simulation. Both tools allow you to use breakpoints as part of a debugging session. However, you use Simulation Stepper and Simulink Debugger for different purposes. The table shows the actions you can perform with each tool.
|Action||Simulation Stepper||Simulink Debugger|
|Look at state of system after executing a major time step.|
|Observe dynamics of the entire model from step to step.|
|Step simulation back.|
|Pause across major steps.|
|Control a Stateflow® debugging session.|
|Step through simulation by major steps.|
|Monitor single block dynamics (for example, output and update) during a single major time step.|
|Look at state of system while executing a major time step.|
|Observe solver dynamics during a single major step.|
|Show various stages of Simulink simulation.|
|Pause within a major step.|
|Step through a simulation block by block.|
|Access via a command-line interface.|
Understanding the simulation process can help you to better understand the differences between Simulation Stepper and Simulink Debugger.