Find graphics objects with specific properties
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 replace prop
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 to
value1
.
The object has a property prop2
whose value is not set to
value2
.
The object has a property prop3
.
h = findobj(
restricts the search to the objects listed in objhandles
,___) 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 in objhandles
,'-depth',d
,___)objhandles
and their
descendants that are up to d
levels lower in the graphics object
hierarchy.
h = findobj(
restricts the search to the objects listed only in objhandles
,'flat',___) objhandles
. The
descendant objects are not searched. Using the 'flat'
option is the same
as using the '-depth'
option with d = 0
.
findobj
does not return graphics objects that have the HandleVisibility
property
set to 'off'
. To return all objects in the hierarchy, including hidden
objects, use the findall
function.
findobj
correctly matches any legal property value. For example,
this code finds all objects having a Color
property set to
red
, 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 time findobj
encounters its
handle. Therefore, implicit references to a graphics object can result in multiple returns
of the object.