findobj
Find graphics objects with specific properties
Syntax
Description
h = findobj
returns the graphics root object and all of its descendants.
h = findobj(
returns all objects in the hierarchy that have the specified properties set to the specified values. You can replaceprop
1,value
1,...,prop
N,value
N)prop,value
pairs with other input argument combinations from the previous syntaxes. For example,h = findobj(prop1,value1,'-not',prop2,value2,'-property',prop3)
returns all objects that satisfy these three conditions:
The object has a property
prop1
set tovalue1
.The object has a property
prop2
whose value is not set tovalue2
.The object has a property
prop3
.
h = findobj(
restricts the search to the objects listed inobjhandles
,___)objhandles
and all of their descendants. You can restrict the search for any of the previous syntaxes.
h = findobj(
restricts the search to the objects listed inobjhandles
,'-depth',d
,___)objhandles
and their descendants that are up tod
levels lower in the graphics object hierarchy.
h = findobj(
restricts the search to the objects listed only inobjhandles
,'flat',___)objhandles
. The descendant objects are not searched. Using the'flat'
option is the same as using the'-depth'
option withd = 0
.
Examples
Input Arguments
Tips
If the
HandleVisibility
property of an object is set to'off'
,findobj
does not return that graphics object or any of its descendants. To return all objects in the hierarchy, including hidden objects, use thefindall
function.findobj
correctly matches any legal property value. For example, this code finds all objects having aColor
property set tored
,r
, or[1 0 0]
:findobj('Color','r')
When a graphics object is a descendant of more than one object identified in
objhandles
, MATLAB searches the object each timefindobj
encounters its handle. Therefore, implicit references to a graphics object can result in multiple returns of the object.