findall
すべてのグラフィックス オブジェクトの検索
説明
h = findall(
は、objhandles
)objhandles
のグラフィックス オブジェクトと、その子孫をすべて返します。関数 findobj
とは異なり、findall
は HandleVisibility
プロパティが 'off'
に設定されている場合でもオブジェクトを返します。
例
ハンドルが表示または非表示の Figure の検索
3 つの Figure を作成します。最後の Figure の HandleVisibility
プロパティを 'off'
に設定します。
f1 = figure; f2 = figure; f3 = figure('HandleVisibility','off');
グラフィックス オブジェクト階層にある表示または非表示のハンドルの数を表示します。実際の結果は、表示されている結果と異なる場合があります。
h1 = findall(groot); disp(numel(h1))
4
表示または非表示のすべての Figure を検索します。
h2 = findall(groot,'Type','figure')
h2 = 3x1 Figure array: Figure (3) Figure (2) Figure (1)
関数 findobj
を使用して Figure を検索しようとすると、MATLAB® では f1
と f2
のみが返されます。
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');
txt
の HandleVisibility
プロパティが '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.
Text オブジェクトの検索
findall
を使用して、すべての Text
オブジェクトまたは特定のプロパティをもつ Text
オブジェクトを返します。
プロットをもつ Figure を作成します。次に、座標軸にラベルを付け、その座標軸にタイトルを加えます。タイトルの色を青に設定します。
plot((1:10).^2) xlabel('x') ylabel('y') title('y = x^2','Color','b')
現在の 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
入力引数
objhandles
— 検索対象のオブジェクト
グラフィックス オブジェクトの配列
検索対象のオブジェクト。グラフィックス オブジェクトの配列として指定します。findall
は入力配列 objhandles
内のオブジェクトと、グラフィックス オブジェクト階層内のそのすべての子孫を検索します。
例: h = findall(groot)
は、グラフィックス オブジェクト階層にある表示および非表示のすべてのハンドルを返します。
prop
— プロパティ名
文字ベクトル | string スカラー
プロパティ名。文字ベクトルまたは string スカラーとして指定します。詳細については、グラフィックス オブジェクトのプロパティを参照してください。
例: h = findall(gcf,'Type','text')
は、現在の Figure 内で Type
プロパティが 'text'
に設定されているすべてのオブジェクトを返します。
value
— プロパティ値
スカラー | 配列
プロパティ値。スカラーまたは配列として指定します。
ヒント
findall
による検索をカスタマイズするには、objhandles
の後に関数findobj
の入力の組み合わせを使用します。以下に例を示します。h = findall(groot,prop1,value1,'-not',prop2,value2,'-property',prop3)
バージョン履歴
R2006a より前に導入
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)