Capturing Simulink Errors

I would like to start a simulation programatically, but I would also like the ability to start, stop, or pause a simulation. In order to do this, I have determined that one must use the command
set_param('ModelName', 'SimulationCommand', 'start');
Unfortunately, I am now not able to record any errors reported by the simulation. By using the sim command, I get an MSLException, but I can't control the simulation state. Are there other options I am missing, or is this the trade off I must deal with?
As a side note, I have used a setup where I insert a subsystem that allows me to control simulation state, but this is a less preferred method, as it edits the model. If it is the only way to do it though, I can continue back on that path.

 采纳的回答

I was able to find the function sllasterror, which provided the appropriate interface by using the following method:
%%%%Reset the last simulink error
sllasterror([]);
%%%%Start Simulation
set_param('ModelName','SimulationCommand','start');
%%%%Retrieve any (possible) error
simError = sllasterror;
if ~isempty(simError)
% Handle error accordingly %
end

更多回答(0 个)

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by