How to open and close all tabs of a Simulink model programmatically?

20 vues (au cours des 30 derniers jours)
How can I open/close all the tabs (have only the main model window open) of a Simulink model programmatically with the "open_system" and "load_system" commands?

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 19 Oct 2022
The "load_system" function loads a Simulink model, without opening any previously opened subsystem or model tabs.
>> sys = load_system('<model>');
>> set_param(sys, 'Open', 'on');
To close subsystem or model tabs in a currently open model, execute the following commands:
>> sys_name = '<model>';
>> sys = find_system(sys_name);
>> subsys = find_system(sys,'BlockType','SubSystem');
>> close_system(subsys);
>> [mdl,~] = find_mdlrefs(sys_name);
>> idx = (strcmp(mdl,sys_name)~=1);
>> close_system(mdl(idx));

Plus de réponses (0)

Catégories

En savoir plus sur Programmatic Model Editing dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by