Stateflow | ![]() ![]() |
Default Transitions
You use default transitions to tell Stateflow which one of several states you enter when you first enter a chart or a state that has substates. See the following topics for information on default transitions:
What Is a Default Transition?
Default transitions are primarily used to specify which exclusive (OR) state is to be entered when there is ambiguity among two or more neighboring exclusive (OR) states. They have a destination but no source object. For example, default transitions specify 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. Default transitions are also used to 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.
One of the most common Stateflow programming mistakes 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 using the Debugger with the State Inconsistencies option enabled.
This table shows the button icon and briefly describes a default transition.
Name |
Button Icon |
Description |
Default transition |
Use a default transition to indicate, when entering this level in the hierarchy, which object becomes active by default. |
Labeling Default Transitions
In some circumstances, you might want to 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.
Note When labeling default transitions, take care to ensure that there is always at least one valid default transition. Otherwise, a Stateflow chart can transition into an inconsistent state. |
![]() | Inner Transitions | Default Transition Examples | ![]() |