문제

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.

도움이 되었습니까?

해결책

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top