Wednesday, August 5, 2009

findobj

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('PropertyName',PropertyValue,...) returns the handles of all graphics objects having the property 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','PropertyName',PropertyValue,...) restricts the search to those objects listed in 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,

  • findobj('Color','r')

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:

  • h = findobj(gca,'Type','line')

No comments:

Post a Comment