image thumbnail
from close all Simulink windows except top-level systems by Noam G
closes all opened windows of Simulink except top-level systems. Can handle several different systems

close_all_subsystem_blocks.m
% for Simulink systems, this routine closes all open windows of subsystems, 
% except the top-level system. Can be used for 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)
clear Blocks_List Blocks_To_Close III

Contact us