Stateflow | ![]() ![]() |
Working with Subcharts
Stateflow allows you to create charts within charts. A chart that is embedded in another chart is called a subchart. The subchart can contain anything a top-level chart can, including other subcharts. In fact, you can nest subcharts to any level.
A subchart appears as a labeled block in the chart that contains it. A subchart is itself a superstate of the states and charts that it contains. You can define actions and default transitions for subcharts just as you can for superstates. You can also create transitions to and from subcharts just as you can create transitions to and from superstates. Further, you can create transitions from states residing outside a subchart to any state within a subchart, and vice versa. The term super transition refers to a transition that crosses subchart boundaries in this way (see Working with Supertransitions for more information).
Subcharts enable you to reduce a complex chart to a set of simpler, hierarchically organized diagrams. This makes the chart easier to understand and maintain. Nor do you have to worry about changing the semantics of the chart in any way. Stateflow ignores subchart boundaries when simulating and generating code from Stateflow models.
Subcharts define a containment hierarchy within a top-level chart. A subchart or top-level chart is said to be the parent of the charts it immediately contains. A subchart or a top-level chart is said to be an ancestor of all the subcharts contained by its children and their descendents.
![]() | Specifying Graphical Function Properties | Creating a Subchart | ![]() |