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.

 採用された回答

David
David 2012 年 1 月 9 日

0 投票

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 ExchangeEvent Functions についてさらに検索

タグ

質問済み:

2012 年 1 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by