Main Content

findall

모든 그래픽스 객체 찾기

설명

예제

h = findall(objhandles)objhandles의 그래픽스 객체와 그 후손을 모두 반환합니다. findall 함수는 findobj와 달리 HandleVisibility 속성이 'off'로 설정된 경우에도 객체를 반환합니다.

예제

h = findall(objhandles,prop1,value1,...,propN,valueN)은 계층 구조에 있는, 지정된 속성이 지정된 값으로 설정된 모든 객체의 핸들을 반환합니다. 예를 들어, h = findall(gcf,'Type','text','Color','r')은 현재 Figure에서 빨간색인 모든 text 객체를 반환합니다.

예제

모두 축소

Figure를 3개 만듭니다. 마지막 Figure의 HandleVisibility 속성을 'off'로 설정합니다.

f1 = figure;
f2 = figure;
f3 = figure('HandleVisibility','off');

그래픽스 객체 계층 구조에 있는 가시적 핸들 또는 숨겨진 핸들의 개수를 표시합니다. 사용자마다 결과는 여기에 표시된 것과 다를 수 있습니다.

h1 = findall(groot);
disp(numel(h1))
     4

보이는 Figure 또는 숨겨진 Figure를 모두 찾습니다.

h2 = findall(groot,'Type','figure')
h2 = 
  3x1 Figure array:

  Figure    (3)
  Figure    (2)
  Figure    (1)

findobj 함수를 사용하여 Figure를 찾으려고 시도하면 MATLAB®은 f1f2만 반환합니다.

h3 = findobj('Type','figure')
h3 = 
  2x1 Figure array:

  Figure    (2)
  Figure    (1)

Figure 내에 있는 Text 객체에는 숨겨진 핸들이 있습니다. findall을 사용하여 숨겨진 핸들을 반환합니다.

플롯이 있는 Figure를 만듭니다. 그런 다음 x축 레이블을 만듭니다.

plot(1:10)
txt = xlabel('My x-axis label');

Figure contains an axes object. The axes object with xlabel My x-axis label contains an object of type line.

txtHandleVisibility 속성이 'off'로 설정되어 있는지 확인합니다.

txt.HandleVisibility
ans = 
'off'

findall을 사용하여 x축 레이블의 Text 객체를 반환합니다.

h1 = findall(gcf,'Type','text')
h1 = 
  Text (My x-axis label) with properties:

                 String: 'My x-axis label'
               FontSize: 11
             FontWeight: 'normal'
               FontName: 'Helvetica'
                  Color: [0.1500 0.1500 0.1500]
    HorizontalAlignment: 'center'
               Position: [5.5000 0.4452 -1.0000]
                  Units: 'data'

  Use GET to show all properties

Text 객체는 숨겨져 있으므로 findobj 함수를 사용하여 찾을 수 없습니다.

h2 = findobj(gcf,'Type','text')
h2 = 
  0x0 empty GraphicsPlaceholder array.

findall을 사용하여 모든 Text 객체 또는 특정 속성을 갖는 Text 객체를 반환합니다.

플롯이 있는 Figure를 만듭니다. 그런 다음, 좌표축에 레이블을 지정하고 제목을 추가합니다. 제목의 색을 파란색으로 설정합니다.

plot((1:10).^2)
xlabel('x')
ylabel('y')
title('y = x^2','Color','b')

Figure contains an axes object. The axes object with title y = blank x Squared baseline, xlabel x, ylabel y contains an object of type line.

현재 Figure에 있는 모든 Text 객체를 반환합니다.

h1 = findall(gcf,'Type','text')
h1 = 
  3x1 Text array:

  Text    (y = x^2)
  Text    (x)
  Text    (y)

이번에는 모든 파란색 Text 객체를 반환합니다.

h2 = findall(gcf,'Type','text','Color','b')
h2 = 
  Text (y = x^2) with properties:

                 String: 'y = x^2'
               FontSize: 11
             FontWeight: 'bold'
               FontName: 'Helvetica'
                  Color: [0 0 1]
    HorizontalAlignment: 'center'
               Position: [5.5000 100.7725 0]
                  Units: 'data'

  Use GET to show all properties

입력 인수

모두 축소

검색될 객체로, 그래픽스 객체로 구성된 배열로 지정됩니다. findall은 입력 배열 objhandles에 있는 객체와 그 후손을 그래픽스 객체 계층 구조에서 모두 검색합니다.

예: h = findall(groot)는 그래픽스 객체 계층 구조에 있는 가시적 핸들과 숨겨진 핸들을 모두 반환합니다.

속성 이름으로, 문자형 벡터 또는 string형 스칼라로 지정됩니다. 자세한 내용은 그래픽스 객체 속성 항목을 참조하십시오.

예: h = findall(gcf,'Type','text')는 현재 Figure에서 Type 속성이 'text'로 설정된 모든 객체를 반환합니다.

속성값으로, 스칼라 또는 배열로 지정됩니다.

  • findall에서 사용할 검색 설정을 사용자 지정하기 위해 objhandles 뒤에 findobj 함수의 입력값 조합이 오도록 할 수 있습니다. 예를 들면 다음과 같습니다.

    h = findall(groot,prop1,value1,'-not',prop2,value2,'-property',prop3)
    

버전 내역

R2006a 이전에 개발됨