limit computation time of a simulink simulation
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Arco
le 2 Fév 2014
Commenté : Subbarao Varigonda
le 3 Juil 2022
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
0 commentaires
Réponse acceptée
Azzi Abdelmalek
le 2 Fév 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 commentaires
Daniel
le 17 Fév 2016
I slightly extended this idea not to wait unnecessary: http://stackoverflow.com/questions/35446636/access-to-cpu-time-during-simulink
Subbarao Varigonda
le 3 Juil 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!
Plus de réponses (2)
Mischa Kim
le 2 Fév 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 commentaires
Mischa Kim
le 2 Fév 2014
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
le 3 Juil 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!
Andreas Goser
le 2 Fév 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
Voir également
Catégories
En savoir plus sur General Applications dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!