Start Simulink simulation and wait for termination
Mostrar comentarios más antiguos
Hi,
My Simulink simulations are governed by a large set of .m files and rather than starting the simulation on my own with Play button, I prefer to call an .m-file which sets up the environment and then starts the simulation.
I run my simulation with
set_param('main','SimulationCommand','start');
However, this call is non-blocking. Is there a good way to block the m-file until the simulation is completed?
I could use polling in a for loop (querying for the state over and over again) but this is clearly not considered a good solution.
I could use the "sim" command but I do not want this because I do not "see" Simulink running (including the states, simulation time etc)
Ideally there would be a "blocking" option to the "SimulationCommand" "start".
Another solution I could think of (not sure if this is supported by MATLAB?) to create an event and let the matlab script wait for an event to signal. The event is then signaled in the "StopFcn" callback. It's important that this solution does not rely on polling ...
Any creative ideas?
Thanks
Respuesta aceptada
Más respuestas (2)
Sviatoslav Klos
el 29 de Ag. de 2018
0 votos
As I see you just need to stop simulation that you start from .m file? Here is the URL with some tutorials (https://www.mathworks.com/help/simulink/ug/control-simulations-programmatically.html). Maybe you can just type set_param('main','SimulationCommand','stop').
If you need smth not I mentioned above maybe 'stop sim' block in Simulink library would be helpful.
Daniel H
el 3 de Sept. de 2018
0 votos
Categorías
Más información sobre Simulation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!