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.

 Accepted Answer

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

More Answers (0)

Categories

Asked:

on 9 Jan 2012

Community Treasure Hunt

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

Start Hunting!