Stateflow User's Guide Previous page   Next Page

State Hierarchy

States can contain all other Stateflow objects except targets. Stateflow notation supports the representation of graphical object hierarchy in Stateflow diagrams with containment. A state is a superstate if it contains other states. A state is a substate if it is contained by another state. A state that is neither a superstate nor a substate of another state is a state whose parent is the Stateflow diagram itself.

States can also contain nongraphical data and event objects. The hierarchy of this containment is represented in the Explorer tool. Data and event containment is defined by specifying the parent object when you create it. See Defining Events and Data and Defining Interfaces to Simulink and MATLAB for information and examples on representing data and event objects in the Explorer tool.

Representing State Hierarchy Example

In the following example, drawing one state within the boundaries of another state indicates that the inner state is a substate or child of the outer state or superstate and the outer state is the parent of the inner state:

In this example, the Stateflow diagram is the parent of the state Car_done. The state Car_done is the parent state of the Car_made and Car_shipped states. The state Car_made is also the parent of the Parts_assembled and Painted states. You can also say that the states Parts_assembled and Painted are children of the Car_made state.

Stateflow hierarchy can also be represented textually, in which the Stateflow diagram is represented by the slash (/) character and each level in the hierarchy of states is separated by the period (.) character. The following is a textual representation of the hierarchy of objects in the preceding example:


Previous page  What Is a State? State Decomposition Next page

© 1994-2005 The MathWorks, Inc.