文档

How Stepping Through a Simulation Works

These topics explain how Simulation Stepper steps through a simulation.

模拟Snapshots

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.

How Simulation Stepper Uses Snapshots

模拟快照捕获了从那时起继续模拟所需的所有信息。设置仿真步进时,您指定:

  • 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.

  • 在快照之间跳过的时间步骤。此设置使您可以定期间隔(例如每三个步骤)向前逐步前进时,可以保存模拟状态的快照。此间隔独立于前进时间或向后的时间步骤的数量。因为拍摄快照会影响仿真速度,所以节省快照的频率较低可以提高模拟速度。

该图显示了如何根据如何在“模拟步进选项”对话框中设置参数的方式来浏览仿真。因为您可以在逐步完成仿真时更改步进参数,所以您可以逐步浏览模拟,如本图所示:有时通过单步,有时是两个或多个步骤。

In the figure, the interval for snapshot captures is three.

下一个图显示了在向前迈进时更改步进选项的优点。在第四步中,存储步骤之间的间隔将快照步骤从三个变为一个。这使您能够捕获围绕感兴趣的模拟时间的更多快照。

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向后移动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.

模拟步进与万博1manbetx调试器

模拟步进和模拟万博1manbetx®调试器既使您可以启动,停止和逐步浏览模型仿真。这两种工具允许您将断点作为调试会话的一部分。但是,您将模拟步进器和Simulink调试器用于不同的目的。万博1manbetx该表显示您可以使用每个工具执行的操作。

行动 模拟Stepper Simulink Debugger
执行重大时间步骤后查看系统状态。
Observe dynamics of the entire model from step to step.
Step simulation back.
Pause across major steps.
控制状态流®debugging session.
逐步逐步逐步逐步。
Monitor single block dynamics (for example, output and update) during a single major time step.
在执行重大时间步骤时查看系统状态。
Observe solver dynamics during a single major step.
显示Simulink模拟的各个阶段。万博1manbetx
Pause within a major step.
Step through a simulation block by block.
通过命令行界面访问。

Understanding the simulation process can help you to better understand the differences between Simulation Stepper and Simulink Debugger.

Related Examples

More About

Was this topic helpful?