Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Close all figures in MATLAB, except specific ones.

I am trying to determine if there is a nice way, to close all figures in MATLAB, except for one(s) that I determine before hand, are not to be closed. Is there such a way to do this?

I am finding that I am wasting a lot of time chasing down specific stuff to close, every time my MATLAB script runs. Thank you.

like image 977
Spacey Avatar asked May 21 '13 22:05

Spacey


1 Answers

You can try this

%figures to keep
figs2keep = [4, 7];

% Uncomment the following to 
% include ALL windows, including those with hidden handles (e.g. GUIs)
% all_figs = findall(0, 'type', 'figure');

all_figs = findobj(0, 'type', 'figure');
delete(setdiff(all_figs, figs2keep));

Here's the link to the source

like image 175
Alexey Avatar answered Nov 11 '22 21:11

Alexey