| Stateflow User's Guide | ![]() |
Entering a State
A state is entered (becomes active) in one of the following ways:
A state performs its entry action (if specified) when it becomes active. The state is marked active before its entry action is executed and completed.
The execution steps for entering a state are as follows:
In the following example, parallel states A and B are aligned at the same vertical level while states A and C and states B and D are aligned at the same horizontal position.
Based on their top-down positions in the diagram editor, the order of entry for these states is A or B, then C, then D. Because A is left of B, A is evaluated first and the order of entry is A, B, D, C. Stateflow marks this order with an order number in the upper right-hand corner of the state (1, 2, 3, 4, respectively)
Step 2 says that if you are entering state D in step 1, check if state B is active. If it is not, start at step 1 for state B. Step 2 repeats for state B and, if A is not active, start at step 1 for A. Since there are no parallel states of lesser entry order, continue with step 3 for state A.
| Entering, Executing, and Exiting a State | Executing an Active State | ![]() |
© 1994-2005 The MathWorks, Inc.