| Stateflow | ![]() |
Types of Transitions
The notation supports these transition types:
See Example: Transitions to and from Exclusive (OR) States for an example of this type of transition.
See Example: Transitions to and from Junctions for an example of this type of transition.
See Example: Transitions to and from Exclusive OR Superstates for an example of this type of transition.
See Default Transitions for examples of this type of transition.
See What Is an Inner Transition? for examples of this type of transition.
See What Is a Self Loop Transition? for examples of this type of transition.
Example: Transitions to and from Exclusive (OR) States
This example shows simple transitions to and from exclusive (OR) states.

The transition On
Off is valid when state On is active and the event Switch_off occurs. The transition Off
On is valid when state Off is active and event Switch_on occurs.
See Transitions to and from Exclusive (OR) States for more information on the semantics of this notation.
Example: Transitions to and from Junctions
This example shows transitions to and from a connective junction.

This is a Stateflow diagram of a soda machine. The Stateflow diagram is called when the external event Selection_made occurs. The Stateflow diagram awakens with the Waiting state active. The Waiting state is a common source state. When the event Selection_made occurs, the Stateflow diagram transitions from the Waiting state to one of the other states based on the value of the variable select. One transition is drawn from the Waiting state to the connective junction. Four additional transitions are drawn from the connective junction to the four possible destination states.
See Example: Transitions from a Common Source to Multiple Destinations for more information on the semantics of this notation.
Example: Transitions to and from Exclusive OR Superstates
This example shows transitions to and from an exclusive (OR) superstate and the use of a default transition.

This is an expansion of the soda machine Stateflow diagram that includes the initial example of the On and Off exclusive (OR) states. On is now a superstate containing the Waiting and soda choices states. The transition Off
On is valid when state Off is active and event Switch_on occurs. Now that On is a superstate, this is an explicit transition to the On superstate.
To be a valid transition to a superstate, the destination substate must be implicitly defined. By defining that the Waiting substate has a default transition, the destination substate is implicitly defined. This notation defines that the resultant transition is Off
On.Waiting.
The transition On
Off is valid when state On is active and event Switch_off occurs. When the Switch_off event occurs, no matter which of the substates of On is active, we want to transition to the Off state. This top-down approach supports the ability to simplify the Stateflow diagram by looking at the transitions out of the superstate without considering all the details of states and transitions within the superstate.
See Default Transitions for more information on the semantics of this notation.
Example: Transitions to and from Substates
This example shows transitions to and from exclusive (OR) substates.

Two of the substates of the On superstate are further defined to be superstates of their own. The Stateflow diagram shows a transition from one OR substate to another OR substate. The transition Waiting.Ready
Orange.In_motion is valid when state Waiting.Ready is active and event Selection_made occurs, providing that the select variable equals one. This transition defines an explicit exit from the Waiting.Ready state and an implicit exit from the Waiting superstate. On the destination side, this transition defines an implicit entry into the Orange superstate and an explicit entry into the Orange.In_motion substate.
See Example: Transition from a Substate to a Substate for more information on the semantics of this notation.
| Valid Transitions | Default Transitions | ![]() |