Stateflow User's Guide Previous page   Next Page

Stateflow Chooses Destinations with Junctions

While states, transitions, and events are the basic building blocks of a state machine, Stateflow also provides decision points in transitions with junctions. Junctions provide an alternative path for transitions.

In the following example, a junction has been added to the preceding diagram.

If the transition from Off to the junction is taken, one of the transitions out of the junction is taken thereafter. In this case, if the temperature is greater than or equal to 30 degrees, the Off state is reentered and the Off state stays active. If not, the transition to the On state is taken and the Off state is exited and the On state becomes active.

You can use flow diagram notation to create decision-making logic such as for loops and if-then-else constructs without the use of states. In some cases, using flow diagram notation provides a closer representation of the required system logic that avoids the use of unnecessary states.


Previous page  Stateflow Reacts to Events Stateflow Uses Data Variables Next page

© 1994-2005 The MathWorks, Inc.