Use Default Transitions to Specify Initial Substate Activity
A default transition specifies which exclusive (OR) state to enter when there is ambiguity among two or more neighboring exclusive (OR) states. A default transition has a destination but no source object. For example, a default transition specifies which substate of a superstate with exclusive (OR) decomposition the system enters by default, in the absence of any other information, such as a history junction. A default transition can also specify that a junction should be entered by default.
Drawing Default Transitions
Click the Default transition button in the toolbar, and click a location in the drawing area close to the state or junction you want to be the destination for the default transition. Drag the mouse to the destination object to attach the default transition. In some cases, it is useful to label default transitions.
A common programming mistake is to create multiple exclusive (OR) states without a default transition. In the absence of the default transition, there is no indication of which state becomes active by default. Note that this error is flagged when you simulate the model with the State Inconsistencies option enabled.
Label Default Transitions
You can label default transitions as you would other transitions. For example, you might want to specify that one state or another should become active depending upon the event that has occurred. In another situation, you might want to have specific actions take place that are dependent upon the destination of the transition.
Tip
When labeling default transitions, ensure that there is at least one valid default transition. Otherwise, a chart can transition into an inconsistent state.
Default Transition Examples
The following examples show the use of default transitions in Stateflow® charts:
Default Transition to a State Example
This example shows a default transition to a state.
The default transition to state PowerOff
ensures that, when the
chart wakes up, the state becomes active. For more information, see Control Chart Execution by Using Default Transitions.
Default Transition to a Junction Example
This example shows a default transition to a connective junction.
The default transition to the connective junction defines that upon entering the chart, the destination depends on the condition of each transition segment.
See Default Transition to a Junction for information on the semantics of this notation.
Default Transition with a Label Example
This example shows a default transition with a label.
When the chart wakes up, the data p
and v
initialize to 10 and 15, respectively.
See Labeled Default Transitions for more information on the semantics of this notation.