| Stateflow User's Guide | ![]() |
Finding Objects at Different Levels of Containment
Once you find a particular object in a Stateflow diagram by its name or another property, you might want to find the objects that it contains (children), or the object that contains it (parent). To find child objects, use the find method. To find a parent object, use the method up.
Finding Child Objects
The find method finds objects at the depth of containment within an object that you specify. If you want to limit the containment search depth with the find command, use the depth switch. For example, to find all the objects in State object sA at the first level of containment, use the following command:
Don't forget, however, that the find command always includes the zeroth level of containment, which is the object itself. So, the preceding command also includes state A in the list of objects found. However, you can exclude state A from the vector of objects in objArray with the MATLAB function setdiff as follows:
The following command returns a collection of all junctions at the first level of containment inside the state A that is represented by State object sA:
The following command returns an array of all transitions inside state A at all levels of containment:
Finding a Parent Object
The up method finds the parent container object of any given object. In the example Stateflow diagram in Create New Objects in the Chart, state A contains states A1 and A2. Also, state A1 contains state A11. In the example, sA11 is a handle to the state A11. This means that
returns a handle pA11 to the state A1, the parent of state A11, and
returns a handle ppA11 to the state A, the parent of state A1.
| Finding Objects | Getting and Setting the Properties of Objects | ![]() |
© 1994-2005 The MathWorks, Inc.