Only close specific figures?

Currently I use this code to close all figures.
figHandles=findobj('Type','figure');
figHandles(1)=[];
close(figHandles)
Say I have up to 5 figures for A data, and 5 other figures for B data. If I "reset" A data, I only want to close those figures, and leave the B data figures open. I assume it would be along the lines of instead of just doing plot, I could do A(i)=plot and B(i)=plot, and close close A or B?

 채택된 답변

the cyclist
the cyclist 2013년 1월 25일

0 개 추천

Are you able to just keep a vector of the figure handles (for A and B separately) as you create them, such that you can close the ones you want? For example,
>> handleA(1) = figure;
>> handleA(2) = figure;
>> % etc
>> handleB(1) = figure;
>> handleB(2) = figure;
>> % etc
Then, to close only A figures, you can do
>> close(handleA)
I guess I'm having trouble understanding your use case.
Also, regarding closing all figures, is there a reason you don't just use
>> close all

댓글 수: 1

Jared
Jared 2013년 1월 25일
That will do the trick. No need for me to keep a vector in this case as I'll always close all of A or B.
I don't use close all as it will also close the GUI window.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Thomas
Thomas 2013년 1월 25일

0 개 추천

You can assign different handles to the individual figures:
fig1 = figure;
fig2 = figure;
close(fig1)

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

태그

질문:

2013년 1월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by