| Stateflow User's Guide |
 |
Simulating Junction Behavior
In this section, you change the model SFcontrol4 you build in Simulating with a Sensor Event, Junction, and Function to demonstrate important junction behavior. Use the following steps to add and test a new function warm and the transition condition that calls it:
- Add the function
warm and a condition that calls it to the SFcontrol4 model as shown.

- Notice that the functions
warm and hot are not complementary. Both functions are true if the temperature is greater than or equal to 120. To determine the outgoing transition segment from the junction, Stateflow applies the following rule:
If several outgoing transitions with conditions are equally valid, Stateflow chooses the outgoing transition with the smallest clock position.
- Leave the value of the Constant block input to the input data
temp at 130 and simulate the model with an on_switch event to observe the following behavior:
Because both hot and warm return a value of true, Stateflow chooses the 6 O'Clock transition segment over the 12 O'Clock one.
|

|
The value for the data speed is set to 1, and the Lo state is active, and stays active, until an off_switch event occurs.
|

|
- You can change this behavior by making a small change in the location of the outgoing transition in the following steps:
- Stop simulation.
- Position the cursor over the source point of the outgoing transition on the junction.
- The cursor changes to a small circle as shown.

- When the circle forms, click-drag the transition source over to the right and release in a position similar to the following:

- Start simulation again.
- Send an
on_switch event by double-clicking the Manual Switch block to move it from the -1 pole to the 1 pole.
Both hot and warm return a value of true. This time Stateflow chooses between the two transition segments by favoring the 1 O'Clock transition segment over the 6 O'Clock one.
|

|
The Hi state becomes active, and stays active until an off_switch event occurs (try it).
|

|
| Simulating with a Sensor Event, Junction, and Function | | Introducing Stateflow Semantics |  |
© 1994-2005 The MathWorks, Inc.