Can I run the simulink debugger programmatically without it opening the model?

1 回表示 (過去 30 日間)
Kai Harth
Kai Harth 2022 年 3 月 8 日
回答済み: Anurag Ojha 2024 年 2 月 1 日
I am running a simulink simulation+debugger programmatically. (This can be either from a GUI, or from matlab in batch mode)
Is there a way to configure the model or the sim+debug commands to not open and pop up the model?
DebuggerCommands = {'slist', 'quit'};
SimOptions = simset('Debug', 'on', 'debug', DebuggerCommands);
sim(<model name>, tfinal, SimOptions);
...
I verified that the model is already loaded when I get to the sim command, and only load_system is used within my scripts.
UPDATE: Just checked, it is the debugger that pops up the model. The sim() command alone will not open the model.
  2 件のコメント
Walter Roberson
Walter Roberson 2022 年 3 月 8 日
sim() does not pop up the model for me when I try -- but i have not turned on debugging when I have done so.
Kai Harth
Kai Harth 2022 年 3 月 8 日
So I double checked and it seems to be the debugger that initiates the opening of the model. Both when I invoke it in the way shown above, as well as invoking sldebug(<model name>)
I'll rephrase my question above....

サインインしてコメントする。

回答 (1 件)

Anurag Ojha
Anurag Ojha 2024 年 2 月 1 日
Hello Kai,
Yes, there is a way to configure the simulation commands to not open the model.
You can set the “OpenFcn” parameter of the model to an empty string using the “set_param” function. This will prevent the model from opening when you run the simulation.
Here's an example of how you can do this programmatically:
modelName = ''; % replace with the actual name of your Simulink model
set_param(modelName, 'OpenFcn', '');
DebuggerCommands = {'slist', 'quit'};
SimOptions = simset('Debug', 'on', 'debug', DebuggerCommands);
sim(modelName, tfinal, SimOptions);
You can refer to following MATLAB documentation to get better understanding of OpenFcn:

カテゴリ

Help Center および File ExchangeProgrammatic Model Editing についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by