Simulation Pacing Options - Slow simulation to a specified ratio of simulation time to wall clock
time - MATLAB ([original](https://in.mathworks.com/help/simulink/slref/simulationpacingoptions.html)) ([raw](?raw))
Slow simulation to a specified ratio of simulation time to wall clock time
Description
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.
When you simulate a model reference hierarchy, only the simulation pacing options specified in the top model apply. Simulation pacing options specified in referenced models are ignored.
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.
Examples
Open the model vdp
.
mdl = "vdp"; open_system(mdl)
Simulate the model.
The simulation completes in just a few seconds.
simMeta = getSimulationMetadata(out); simMeta.TimingInfo.TotalElapsedWallTime
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.
set_param(mdl,"EnablePacing","on")
The icon for the Run button icon is annotated with a clock to indicate that simulation pacing is enabled.
To view the signals x1
and x2
during the paced simulation, double-click the Scope block.
Simulate the model again. On the Simulation tab, click Run. Alternatively, use the sim
function.
The Scope block updates to display the data for the signals x1
and 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.35
seconds of simulation time per second. - In the Simulink Toolstrip, on the Simulation tab, click Run.
- Double-click the block named
Mu
. - 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
x1
andx2
in the Scope block.
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.
Related Examples
- Tune and Visualize Your Model with Dashboard Blocks
- Step Through Simulations Using the Simulink Editor
- Debug Simulation Using Signal Breakpoints
Parameters
Option to slow simulation, specified as off
oron
.
Programmatic Use
Parameter: EnablePacing |
---|
Value: "off" | "on" |
Default: "off" |
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.
Dependencies
To enable this parameter, select Enable pacing to slow down simulation.
Limitations
Tuning the value of the PacingRate
parameter using theset_param
function is not supported in rapid accelerator simulations run:
- By using the Simulink Editor
- By issuing the
"start"
simulation command
set_param(mdl,SimulationCommand="start")
Programmatic Use
Parameter: PacingRate |
---|
Type: string | character vector |
Value: positive scalar number |
Default: "1" |
Tips
- The simulation pacing does not apply when you step through a simulation by clickingStep 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 theSimulink Profiler is not supported when simulation pacing is enabled. To use the Simulink Profiler, disable simulation pacing.
- To specify and tune simulation pacing options in simulations and App Designer apps that use the Simulation object, use the setModelParameter function.
Version History
Introduced in R2018a