| MATLAB Function Reference | ![]() |
Locate graphics objects with specific properties
Syntax
h = findobj h = findobj('PropertyName',PropertyValue,...) h = findobj(objhandles,...) h = findobj(objhandles,'flat','PropertyName',PropertyValue,...)
Description
findobj locates graphics objects and returns their handles. You can limit the search to objects with particular property values and along specific branches of the hierarchy.
h = findobj
returns the handles of the root object and all its descendants.
h = findobj(' returns the handles of all graphics objects having the property PropertyName',PropertyValue,...)
PropertyName, set to the value PropertyValue. You can specify more than one property/value pair, in which case, findobj returns only those objects having all specified values.
h = findobj(objhandles,...)
restricts the search to objects listed in objhandles and their descendants.
h = findobj(objhandles,'flat',' restricts the search to those objects listed in PropertyName',PropertyValue,...)
objhandles and does not search descendants.
Remarks
findobj returns an error if a handle refers to a non-existent graphics object.
Findobj correctly matches any legal property value. For example,
finds all objects having a Color property set to red, r, or [1 0 0].
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 its handle being returned multiple times.
Examples
Find all line objects in the current axes:
See Also
copyobj, gcf, gca, gcbo, gco, get, set
axes, figure, image, light, line, patch, surface, text, uicontrol, uimenu
Finding and Identifying Graphics Objects for related functions
| findfigs | findstr | ![]() |