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

22 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 19 de Oct. de 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));

Más respuestas (0)

Categorías

Más información sobre Programmatic Model Editing en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by