findobj
Finds all objects which have a property named propertyName and the value for such property is propertyValue.
Syntax
findobj(propertyName, propertyValue, ...)
findobj(propertyName, propertyValue, '-operator', propertyName, propertyValue)
findobj('-property', propertyName)
findobj(handleList, propertyName, propertyValue, ...)
findobj(handleList, '-depth', depth, ...)
findobj(handleList, 'flat', ...)
Inputs
- propertyName
- Property name. If the property name is following the keyword '-property' then the search will return all objects that have this property.
- propertyValue
- Value of the property.
- -operator
- A logical operator that is applied on the pair of properties and values. Valid values are: '-and', '-or', '-xor' and '-not'.
- handleList
- Vector of the handles.
- depth
- Limits the search to a certain object hierarchy depth. A depth of 0 will limit the search to the objects in the given handleList.
- 'flat'
- Keyword 'flat' will limit the search to the objects in the given handleList.
Examples
Simple findobj example:
findobj('tag', 'user-defined');
Find all objects that have the property 'xdata':
findobj('-property', 'xdata');
Find objects that are colored red or have the marker 'o':
findobj('color', [255 0 0], '-or', 'marker', 'o');
Limit the search to the children of a figure object:
findobj(gcf, '-depth', 1, 'tag', 'user-defined');
Comments
To find objects that satisfy multiple property conditions, specify additional propertyName and propertyValue parameters. The search can be limited to a subset of objects and their descendants by passing a handle or a handles list as the first parameter.