Stateflow User's Guide Previous page   Next Page

Entering Truth Table Actions

During execution of the truth table, decisions are tested in left to right order. When a decision is realized during execution of the truth table, the action in the Action Table specified in the Actions row for that decision column is executed and the truth table is exited.

In Entering Truth Table Decisions you enter decisions in the truth table editor. The next step is to enter the actions you want to occur for each decision in the Action Table. Later, you assign these actions to their decisions in the Actions row of the Condition Table.

  1. Click anywhere in the Action Table to select it.
  2. Click the Append Row toolbar button three times to add three rows to the bottom of the Action Table.
  3. Click and drag the bottom border of the truth table editor window down to enlarge it and clearly show all rows of the Action Table, as shown.

  4. Click the top cell in the Description column of the Action Table.
  1. The cell is highlighted and a flashing text cursor appears in the cell.

  1. Enter the following description:
  1. Action descriptions are optional, but are carried into the generated code for the truth table as code comments.

  1. Press Tab to select the next cell on the right, in the Action column.
  2. Enter the following text:
  1. You begin an action with an optional label followed by a colon (:). Later, you enter these labels in the Actions row of the Condition Table to specify an action for each decision column. Like condition labels, action labels must begin with an alphabetic character ([a-z][A-Z]) followed by any number of alphanumeric characters ([a-z][A-Z][0-9]) or an underscore (_).

  1. Press Enter and enter the following text:
  1. You can use data passed to the truth table function through its arguments and return value in truth table actions. The preceding action, t=1, sets the value of the return value t. You can also specify actions with data defined for a parent object of the truth table, including the Stateflow diagram. Truth table actions can also broadcast or send events that are defined for the truth table, or for a parent, such as the diagram (chart) itself.

    If you omit the semicolon at the end of an action, the result of the action is echoed to the MATLAB window when it is executed during simulation. Use this as a debugging tool.

  1. Enter the remaining actions in the Action Table, as shown in the following:


Previous page  Entering Truth Table Decisions Assigning Truth Table Actions to Decisions Next page

© 1994-2005 The MathWorks, Inc.