Stateflow User's Guide Previous page   Next Page

Stateflow Reacts to Events

Events provide the motivation that a model needs for taking a transition between states. An event can represent the point at which the temperature in a room exceeds a given temperature. An event can represent the point that water in a container reaches its top level requiring that the flow of water to it be shut off. Normally, the physical plant modeled in Simulink originates these events, which trigger a Stateflow block that responds to them.

An important thing to remember is that Stateflow diagrams become active only if an event occurs. Also, no transition from the active state to another state takes place without an event. In the preceding example, if the Off state is active and no later event is received, the Off state stays active.

Events can be specific in Stateflow, and the diagram can watch for specific events with the event triggers, as shown in the following example:

In this example, the transition from the Off state to the On state takes place only if the Off state is active and the event on_switch is received. Also, the transition from the On state to the Off state takes place only if the On state is active and the event off_switch is received.


Previous page  Stateflow Changes Active States with Transitions Stateflow Chooses Destinations with Junctions Next page

© 1994-2005 The MathWorks, Inc.