Simulation Pacing Options
Slow simulation to a specified ratio of simulation time to wall clock time
Use simulation pacing to slow simulation to help analyze and interact with your model. When you pace the simulation, visualizations such as Scope blocks and dashboard blocks update at the slower rate. With simulation pacing enabled, you can modify parameters in the model and observe the effect of the change in the model.
Simulation pacing can be useful in models where the software computes the results for a second of simulation time in a few milliseconds of clock time.
Open the Simulation Pacing Options
In the Simulink® Toolstrip, on the Simulation, Debug, or Modeling tab, click the Run button arrow. Then, select Simulation Pacing.
Pace Simulation of Model
Open the model
mdl = "vdp"; open_system(mdl)
Simulate the model.
out = sim(mdl);
The simulation completes in just a few seconds.
simMeta = getSimulationMetadata(out); simMeta.TimingInfo.TotalElapsedWallTime
ans = 17.1552
To better observe how the signal values change during simulation, enable simulation pacing.
In the Simulink® Toolstrip, on the Simulation tab, click the Run button arrow, then select Simulation Pacing.
In the Simulation Pacing Options dialog box, select Enable pacing to slow down simulation.
Alternatively, use the
set_param function to enable simulation pacing.
The icon for the Run button icon is annotated with a clock to indicate that simulation pacing is enabled.
To view the signals
x2 during the paced simulation, double-click the Scope block.
Simulate the model again. On the Simulation tab, click Run. Alternatively, use the
out = sim(mdl);
The Scope block updates to display the data for the signals
x2 as the simulation runs.
While a paced simulation runs, you can modify block parameters, add and remove port value labels, and navigate through a model hierarchy the same way you can during a simulation without pacing. You can also enable or disable simulation pacing and adjust the pacing rate during simulation.
For example, run another paced simulation and change the value of the Gain parameter for the block named
Mu during the simulation. For this simulation, decrease the ratio of simulation time to wall clock time to ensure you have sufficient time to modify the parameter and see the effect of the change in the Scope block.
In the Simulation Pacing Options dialog box, drag the value slider or enter a value in the field to decrease the simulation pace to an approximate ratio of
0.35seconds of simulation time per second.
In the Simulink Toolstrip, on the Simulation tab, click Run.
Double-click the block named
Use the slider in the custom Block Parameters dialog box for the masked block to adjust the value of the Gain parameter. Monitor the effect of changing the Gain parameter on the signals
x2in the Scope block.
Use Simulation Pacing with Dashboard Blocks
You can use dashboard blocks to view signals and tune variable and parameter values in your model while slowing a simulation using simulation pacing. Using dashboard blocks with simulation pacing allows you to build an intuitive understanding of your model and how the model responds to changes as you tune parameters in your model.
The example model uses simulation pacing to slow the simulation pace to approximately equivalent to wall clock time, or one simulation second per wall clock second. The model has a button labeled Signal Select that you can use to control whether the sine wave or sawtooth input signal passes to the output, which is visualized using a Dashboard Scope block.
Open the model and run a simulation. During the simulation, press and release the Signal Select button and observe the effect on the output signal.
For more information about creating the example model, see Control Merging Signals with the Push Button Block.
Enable pacing to slow down simulation — Option to slow simulation
off (default) |
Option to slow simulation, specified as
Simulation time per wall clock second — Approximate ratio of simulation time to wall clock time
1 (default) | positive scalar number
Approximate ratio of simulation time to wall clock time, specified as a positive scalar number. By default, when you enable simulation pacing, the software slows the simulation to a rate of approximately one second of simulation time per second of clock time.
You can use the value slider or the text box to specify the approximate pacing rate. The ratio of simulation time to clock time is not limited to the range shown in the value slider.
To enable this parameter, select Enable pacing to slow down simulation.
|Type: string | character vector|
|Value: positive scalar number|
The simulation pacing does not apply when you step through a simulation by clicking Step Forward or Step Backward. When you finish stepping and click Continue, the pacing does apply.
Because simulation pacing intentionally slows simulation, profiling a model using the Simulink Profiler is not supported when simulation pacing is enabled. To use the Simulink Profiler, disable simulation pacing.
Introduced in R2018a