Effacer les filtres
Effacer les filtres

How to pause a simulation in Simulink at a certain timestep with a variable step solver?

13 vues (au cours des 30 derniers jours)
I would like to pause my simulation every 900 seconds, change one parameter and keep on simulating. Now I have the problem, that by using a solver with variable step size, the simulation doesn't allways stop at exact a multiple of 900 seconds. Does someone know how I can pause the simulation and not use a fixed step size solver?
Thanks a lot!

Réponses (1)

Pavan Sahith
Pavan Sahith le 10 Nov 2023
Hello Lina,
I understand that you want to pause your simulation 900 seconds, change one parameter and keep on simulating while using a variable step solver.
In Simulink , general approach to achieve this is
  1. Create a "Clock" block or a source of time information that outputs the simulation time.
  2. Use a "Relational Operator" block to check if the current time is a multiple of 900 seconds.
  3. Use a "Triggered Subsystem" block to pause the simulation when the time condition is met. The Triggered Subsystem block can be set up to run the subsystem when the condition is true.
  4. Inside the "Triggered Subsystem" you can make the parameter changes or any other operations you need to perform.
  5. Use a "Assertion" or "Stop" block to pause the simulation, or you can create a custom pause mechanism within the Triggered Subsystem.
You can try the above approach ,one thing to note here is ,when using a variable step solver, the solver adapts the time step dynamically to ensure the simulation's accuracy and stability. This adaptive behavior may lead to the simulation stopping slightly before or after the exact time condition (e.g., multiples of 900 seconds) you intend to pause.
To mitigate this issue and ensure that the simulation stops at or very close to the desired time intervals, I think you can use methods like tightening solver tolerances.
Please refer to this MathWorks documentation which might help you
  1. 'Simulate a Model Interactively'- https://in.mathworks.com/help/simulink/ug/controlling-execution-of-a-simulation.html
  2. https://in.mathworks.com/help/simulink/ug/solver-exception-events.html
Hope that helps


En savoir plus sur General Applications dans Help Center et File Exchange




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by