How to open and close all tabs of a Simulink model programmatically?
20 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 19 Oct 2022
Réponse apportée : MathWorks Support Team
le 19 Oct 2022
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
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));
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Programmatic Model Editing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!