| Stateflow® | ![]() |
| On this page… |
|---|
Condition and Transition Actions Example Condition Actions in For-Loop Construct Example Condition Actions to Broadcast Events to Parallel (AND) States Example |
This example shows the behavior of a simple condition action in a multiple segment transition.

Initially, the Stateflow chart is asleep. State A is active. Event E_one occurs and awakens the chart. Conditions C_one and C_two are false. Event E_one is processed from the root of the chart down through the hierarchy of the chart:
The Stateflow chart root checks to see if there is a valid transition as a result of E_one. A valid transition segment from state A to a connective junction is detected. The condition action A_one is detected on the valid transition segment and is immediately executed and completed. State A is still active.
Because the conditions on the transition segments to possible destinations are false, none of the complete transitions is valid.
State A during actions (durA()) execute and complete.
State A remains active.
This sequence completes the execution of this Stateflow chart associated with event E_one when state A is initially active.
This example shows the behavior of a simple condition and transition action specified on a transition from one exclusive (OR) state to another.

Initially, the Stateflow chart is asleep. State A is active. Event E_one occurs and awakens the chart. Condition C_one is true. Event E_one is processed from the root of the chart down through the hierarchy of the chart:
The Stateflow chart root checks to see if there is a valid transition as a result of E_one. A valid transition from state A to state B is detected. The condition C_one is true. The condition action A_one is detected on the valid transition and is immediately executed and completed. State A is still active.
This sequence completes the execution of this Stateflow chart associated with event E_one when state A is initially active.
Condition actions and connective junctions are used to design a for loop construct. This example shows the use of a condition action and connective junction to create a for loop construct.

See For-Loop Construct Example to see the behavior of this example.
This example shows how to use condition actions to broadcast events immediately to parallel (AND) states.

See Event Broadcast Condition Action Example to see the behavior of this example.
This example shows a notation to avoid when using event broadcasts as condition actions because the semantics results in cyclic behavior.

Initially, the Stateflow chart is asleep. State On is active. Event E_one occurs and awakens the chart. Event E_one is processed from the root of the chart down through the hierarchy of the chart:
The Stateflow chart root checks to see if there is a valid transition as a result of E_one.
A valid transition from state On to state Off is detected.
The condition action on the transition broadcasts event E_one.
Event E_one is detected on the valid transition, which is immediately executed. State On is still active.
The broadcast of event E_one awakens the chart a second time.
Steps 1 - 5 continue to execute in a cyclical manner. The transition label indicating a trigger on the same event as the condition action broadcast event results in unrecoverable cyclic behavior. This sequence never completes when event E_one is broadcast and state On is active.
![]() | Transitions to and from Exclusive (OR) States Examples | Default Transition Examples | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |