Stateflow | ![]() ![]() |
Finding Objects
There are several object methods that you use to traverse the Stateflow hierarchy to locate existing objects. Chief among these is the versatile find
method.
With the find
method, you specify what to search for by specifying combinations of the following types of information:
The following example searches through machine (model) m
to return every State object with the name 'On'.
If a find
command finds more than one object that meets its specifications, it returns an array of qualifying objects. The following example returns an array of all charts in your model:
Use array indexing to access individual properties and methods for a chart. For example, if the preceding command returns three Stateflow charts, the following command returns the Name property of the second chart found:
By default, the find
command finds objects at all depths of containment within an object. This includes the zeroth level of containment, which is the searched object itself. For example, if state A
, which is represented by State object sA
, contains two states, A1
and A2
, and you specify a find
command that finds all the states in A
as follows,
The preceding command finds three states: A
, A1
, and A2
.
Note
Be careful when specifying the objects you want to find with the find method for a Root or Machine object. Using the find method for these objects can return Simulink objects matching the arguments you specify. For example, if rt is a handle to the Root object, the command find('Name', 'ABC') might return a Simulink subsystem or block named ABC . See the reference for the find method for a full description of the method and its parameters.
|
![]() | Accessing Existing Stateflow Objects | Finding Objects at Different Levels of Containment | ![]() |