How does one programatically stop simulation based on actual time elapsed?

I have a simulink file 'mysim.slx' that I would like to simulate multiple times. Each time, I am passing a different set of parameters specifying the physical properties of a system (properties like mass/damping/stiffness/etc). However, some combinations of parameters may produce an unstable system (partially due to some nonlinearities in the system) and I do not necessarily know if a certain set of parameters will produce this behavior. Because each simulation is computationally heavy and a problematic set of parameters causes the simulation to run more slowly, I would like to be able to abort the current simulation if the actual time exceeds some value (say, 60s). I am NOT talking about the simulation time - I understand that the simulation will naturally complete once it reaches that threshold. I want to be able to cut the simulation short if it is taking too long. The reason I would like to do it programatically is because I would like to be able to compare results between simulations without having to Ctrl-C every time the simulation stalls.
In addition, I do not want to simply kill all processes - because I want to run multiple versions of the simulation in succession (by calling the slx file with sim('mysim.slx') in an m-file), I would like to be able to simply cut the current simulation short and then move on with the program.
Currently, I am calling the simulation in my m-file and timing it like this:
% 'param' is some value that is used in the simulation
for param = 1:n
tic
sim('mysim.slx')
toc
% Then take the data, plot it, do some stuff
end
Is there a way to do this?

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Simulink 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by