필터 지우기
필터 지우기

Closing specific figure handles

조회 수: 1 (최근 30일)
Jared
Jared 2013년 2월 1일
I asked a similar question before, but haven't been able to get the behavior I am looking for.
Example. I can have up to 4 plots p(1)=figure, p(2), p(3), p(4)... I can also have up to 4 histograms h(1)=figure, h(2), h(3), h(4)...
Using a for loop to determine the user desired output, figures are created, then the plot or histogram is "put in" each figure.
Due to the nature of how I am creating the figures, I am not sure which ones are open, so I can't just do:
close(p(1)); close(p(2)); close(p(3)); close(p(4));
Same for h(i). Is there a way to close all of p, or h, with a single command, no matter if one or all of them are open?

채택된 답변

Matt Tearle
Matt Tearle 2013년 2월 1일
편집: Matt Tearle 2013년 2월 1일
Why not just do close(h)?
If there's a possibility that h never gets created at all (no histograms), you can use exist to check before doing the close
if exist('h','var')
close(h)
end
EDIT Rereading the question, perhaps the problem is that h(2) may exist as a variable, but not refer to a valid figure? In that case,
close(h(ishandle(h)))

추가 답변 (1개)

Shashank Prasanna
Shashank Prasanna 2013년 2월 1일
close(findobj('type','figure'))
Closes all figures.
  댓글 수: 1
Jared
Jared 2013년 2월 1일
I don't want to close all figures. I want to close all p figures, or all h figures, while leaving the others open. Can findobj be used to find the handle p or h?

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

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by