Borrar filtros
Borrar filtros

How to close Simulink model subsystems

10 visualizaciones (últimos 30 días)
Noam G
Noam G el 13 de Mzo. de 2012
Respondida: Pablo Romero el 14 de Sept. de 2015
For a given model, I am looking for an easy way to close all open subsystems' windows, except the basic one. If I close them all, save the model and reopen it, it works, but I want to do the same with code.

Respuestas (5)

TAB
TAB el 14 de Mzo. de 2012
No need of using lots of variables & loop. Just find all the subsystems in the model and close them.
close_system(find_system('YouModel','findall','on','BlockType','SubSystem'));

Honglei Chen
Honglei Chen el 13 de Mzo. de 2012
doc bdclose
doc close_system

Doug Eastman
Doug Eastman el 13 de Mzo. de 2012
Assuming your top-level model is called TopModel you could use:
a = find_system('Parent','TopModel');
close_system(a)

Noam G
Noam G el 14 de Mzo. de 2012
Based on Doug Eastman's tip, I came up with the following code. It closes all the subsystem except the top levels (of several systems):
Blocks_List = find_system;
Blocks_To_Close = Blocks_List;
for III=length(Blocks_List):-1:1
if isempty(strfind(Blocks_List{III},'/'))
Blocks_To_Close(III)=[];
end
end
close_system(Blocks_To_Close)

Pablo Romero
Pablo Romero el 14 de Sept. de 2015
There is a small trick. You can load again the top-level of the system and save it (if requested).
open_system(bdroot); % Load the top-level
close_system(bdroot, 1); % Save and close the Model
Of course you can use your Modelname instead of bdroot.

Categorías

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

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by