Frage

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.

War es hilfreich?

Lösung

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

Andere Tipps

Probably the safest way is to assign handles to variables h1, h2, ... for each of your figures as you generate them and then use close(handle) to close the figures you don't want open.

close() also takes a vector/matrix of handles as an input, so you could always aggregate a vector of handles of figures to be closed.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top