limit computation time of a simulink simulation

10 visualizzazioni (ultimi 30 giorni)
Hi,
is it possible, to set a time limit for a simulink simulation? When the time limit is reached, the simulation should be aborted.
Edit: I need a time limit for the computation time.
Thanks, Arco

Risposta accettata

Azzi Abdelmalek
Azzi Abdelmalek il 2 Feb 2014
You can control your simulink model by using a set_param command.
set_param('your_simulink_model_name', 'SimulationCommand', 'start')
%use a pause command
pause(200) % wait 200 second
set_param('your_simulink_model_name', 'SimulationCommand', 'stop')
  3 Commenti
Subbarao Varigonda
Subbarao Varigonda il 3 Lug 2022
Thank you, the method described and code given here is very helpful!
It does seem to work for simple, well behaved models.
However, we do see cases where Simulink model simulations get stuck and pressing stop from the Simulink does not terminate the simulation and return control. It is not clear if the command
set_param(model,'SimulationCommand','stop')
can force termination of the simulation on a priority basis and is more reliable than pressing the "stop" button on GUI.
When doing large scale batch runs of simulink models, we need highly reliable way of terminating the simulation from within Matlab/Simulink model or simulation setup scripts based on allocated CPU or wall clock time rather than relying on external scheduler or OS functions for this.
Appreciate a clarification. Thanks!

Accedi per commentare.

Più risposte (2)

Mischa Kim
Mischa Kim il 2 Feb 2014
Sure, in the model window the simulation time can be entered (in sec). In the figure below it is set to 10 sec.
  3 Commenti
Mischa Kim
Mischa Kim il 2 Feb 2014
Oh, I see. Check out the documentation.
To begin with you could try to change error tolerances and/or set a lower limit on the minimum step size (> Simulation > Model Configuration Parameters).
Subbarao Varigonda
Subbarao Varigonda il 3 Lug 2022
Would like to know the direct answer to the question asked here. Can a Simulink model be run with a wall clock or CPU time constraint? As stated by the original poster of this question, there are times when parameter values used may be bad and simulation may get stuck. We are not interested here in making the simulation work for such cases as it is not practical to do when running a large number of cases in a design of experiments setting. We simply need Simulink simulation to self-terminate (possibly with return status indicating this) if it is not completed successfully in allocated time. If this feature is not supported by Simulink and Matlab scripting language to run Simulink models, please consider adding this. Thank you!

Accedi per commentare.


Andreas Goser
Andreas Goser il 2 Feb 2014
You may want to abort a simulation based on your results being in a range that make you sure those parameter are not good. Check out this library

Categorie

Scopri di più su Simulink in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by