Stateflow User's Guide Previous page   Next Page

Adding State Entry Actions

You modify data in Stateflow with actions. Actions are programming lines that you add to states or transitions in Stateflow diagrams. In this topic, you use state entry actions to change a data value that provides control information to the Simulink model. For now, assume that your diagram defines a data named speed that you pass to the Simulink model. You add a state entry action to modify the value of speed to indicate the speed of a device (for example, a motor) that you are controlling to the Simulink model.

Add entry actions to the labels of the states On and Off to modify the data speed with the following steps:

  1. Place the mouse cursor over the name of the On state.
  1. Notice that the mouse cursor changes to a text cursor over the state label.

  1. Click when the text cursor is at the end of the name of the On state.
  1. This highlights the state and its label and a blinking text cursor appears at the end of the label, which contains only the name On.

  1. Press Enter and enter the following text line.
  2. Click outside of the state when finished entering text.
  1. The Controller Stateflow diagram should appear similar to the following:

    The label for the On state now includes a name for the state (On) and an entry action, which is identified by the prefix en:. This entry action assigns the data speed a value of 1 when the state On becomes active.

  1. Repeat the preceding steps to add the following entry action to the state Off:
  1. The Controller Stateflow diagram should appear similar to the following:


Previous page  Modifying Output Data with Actions Adding Output Data to the Stateflow Chart Next page

© 1994-2005 The MathWorks, Inc.