Return specified objects
objArray = thisObject.find(Specifier,Value, ...)
Using combinations of specifier-value argument pairs, the
returns objects in this object that match the specified criteria. The
specifier-value pairs can be property based or based on other attributes of the
object such as its depth of containment. Specifiers can also be logical operators
-or, and so on) that combine other
By default, the
find command finds objects at all depths of containment
within an object. You can specify the maximum depth of search by using the
-depth specifier. However, the zeroth level of containment,
that is, the searched object itself, is always included if it satisfies the search
If no arguments are specified, the
returns all objects of this object at all levels of containment.
The object for which to find contained objects. Can be an object of type Root, Machine, State, Box, Function, or Truth Table.
No value is paired to this specifier. Instead, this specifier relates a previous specifier-value pair to a following specifier-value pair in an AND relation.
If no logical operator is specified,
Name of the class to search for. Use this option to find all objects whose class
exactly matches a given class. To allow matches for subclasses
of a given class, use the
Integer depth to search, which can be 0, 1, 2,..., infinite. The default search depth is infinite.
Handle to a function that evaluates each object visited in the search. The function must always return a logical scalar value that indicates whether or not the value is a match. If no property is specified, the function is passed the handle of the current object in the search. If a property is specified, the function is passed the value of that property.
In the following example, a
function with handle
f = @(h) (strcmp(get(h,'type'), 'andState')); objArray = thisObject.find('-function', f);
Name of the type of objects to search for. Object types are specified as a name (e.g.,
Name of a method belonging to the objects to search for.
No value is paired to this specifier. Instead, this specifier searches for the negative of the following specifier-value pair.
No value is paired to this specifier. Instead, this specifier relates the previous specifier-value pair to the following specifier-value pair in an OR relation.
The specifier takes on the name of the property. Value of the specified property for the objects you want to find.
Name of the property that belongs to the objects you want to find.
No value is paired to this specifier. Instead, this specifier relates the previous specifier-value pair to the following specifier-value pair in an XOR relation.
No value follows this specifier. Instead, this specifier indicates that the value of
the following specifier-value pair contains a regular
expression. For more information, see
Array of objects found matching the criteria specified.
If a Chart object
c represents a Stateflow® chart, to produce an array of all the states in the chart, use this
states = c.find('-isa','Stateflow.State')
'A', use this command:
objects = c.find('Name','A')
Nameproperty starts with the letter
A, use this command:
states = c.find('-isa','Stateflow.State','-and','-regexp','Name','^A')