| Stateflow User's Guide | ![]() |
Transition Label Notation
A transition is characterized by its label. The label can consist of an event, a condition, a condition action, and/or a transition action. The ? character is the default transition label. Transition labels have the following general format:
You replace the names for event, condition, condition_action, and transition_action with appropriate contents as shown in the example Transition Label Example. Each part of the label is optional.
Transition Label Example
Use the transition label in the following example to understand the parts of a transition label.
Event Trigger. specifies an event that causes the transition to be taken, provided the condition, if specified, is true. Specifying an event is optional. The absence of an event indicates that the transition is taken upon the occurrence of any event. Multiple events are specified using the OR logical operator (|).
In the preceding example, the broadcast of event E triggers the transition from On to Off provided the condition [off_count==0] is true.
Condition. specifies a boolean expression that, when true, validates a transition to be taken for the specified event trigger. Enclose the condition in square brackets ([]). See Conditions for information on the condition notation.
In the preceding example, the condition [off_count==0] must evaluate as true for the condition action to be executed and for the transition from the source to the destination to be valid.
Condition Action. A condition action follows the condition for a transition and is enclosed in curly braces ({}). It is executed as soon as the condition is evaluated as true and before the transition destination has been determined to be valid. If no condition is specified, an implied condition evaluates to true and the condition action is executed.
In the preceding example, if the condition [off_count==0] is true, the condition action off_count++ is immediately executed.
Transition Action. The transition action is executed after the transition destination has been determined to be valid provided the condition, if specified, is true. If the transition consists of multiple segments, the transition action is only executed when the entire transition path to the final destination is determined to be valid. Precede the transition action with a backslash.
In the preceding example, if the condition [off_count==0] is true, and the destination state Off is valid, the transition action Light_off is executed.
| Transition Hierarchy | Valid Transitions | ![]() |
© 1994-2005 The MathWorks, Inc.