| Stateflow User's Guide | ![]() |
Drawing Transitions in a Stateflow Diagram
States in a Stateflow diagram can be active or inactive. In Drawing States in Stateflow Diagrams, you draw an On state and an Off state for the SFcontrol1 model. An active Off state indicates the device you are controlling is off, and an active On state indicates that the device is on.
Because a device such as a motor or a fan cannot be on and off at the same time, only one state can be active at a time. The diagram needs to define a way to change the control state of the device from Off to On and from On to Off. Transitions in a Stateflow diagram define a path along which an active state can become inactive and another state can become active. In this topic, you draw transitions between the Off state and the On state with the following steps:
Notice that a transition is directional. This transition proceeds from the Off state to the On state. This means that if the Off state is active, the On state can become active and the Off state inactive through this transition.
You need to add one last transition to tell the Stateflow diagram which of the two states, Off or On, is active when the Stateflow diagram starts operating. You use a default transition to specify the Off state as the first active state with the following steps:
| Drawing States in Stateflow Diagrams | Adding a Trigger Event to the Stateflow Diagram | ![]() |
© 1994-2005 The MathWorks, Inc.