Stateflow User's Guide Previous page   Next Page

Adding and Connecting Junctions

You use junctions to provide alternate paths for transitions. This lets the Stateflow diagram choose the destination state for a transition based on a condition or set of conditions. In this section, you add a junction that chooses between two destination states for a transition based on the value of the temperature. This represents the choice of one of two possible speeds for the device you are controlling, such as a motor.

Place a junction between the two states Hi and Lo and connect it with the following steps:

  1. From the drawing toolbar on the left, click the Junction tool .
  2. Move the cursor into the drawing area and place a junction between the states Hi and Lo as shown.

  3. Draw a transition from the top border of the junction to the bottom border of the state Hi just as you would between two states.
  4. Draw another transition from the junction down to the top of the state Lo.
  1. The Stateflow diagram now has the following appearance:

  1. Draw a transition from the top of the state Off to the right side of the junction and label it with the event trigger on_switch as shown.

The transition from the Off state now has two possible destinations: Hi and Lo. To make a choice between these destinations, you need to add a condition to one of the transitions out of the junction in Entering Transition Conditions.


Previous page  Deleting, Copying, and Renaming Stateflow Objects Entering Transition Conditions Next page

© 1994-2005 The MathWorks, Inc.