Stateflow User's Guide Previous page   Next Page

Entering Truth Table Conditions

Conditions are the starting point for specifying logical behavior in a truth table. You open the truth table ttable for editing in Opening a Truth Table for Editing. In this topic, you start programming the behavior of ttable by specifying its conditions.

You enter conditions in the Condition column of the Condition Table. For each condition that you enter, you can also enter an optional description in the Description column. Use the following procedure to enter the conditions of the truth table ttable:

  1. Click anywhere in the Condition Table to select it.
  2. Click the Append Row tool twice.
  1. Two rows are appended to the bottom of the Condition Table for a total of three, as shown.

    The Action row of the Condition Table is slightly obscured by the pane of the Action Table.

  1. Click and drag the bar separating the Condition Table and the Action Table panes down to enlarge the Condition Table pane.
  2. In the Condition Table, click the top cell of the Description column.
  1. The cell is highlighted and a flashing text cursor appears in the cell.

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

  1. Press the Tab key to select the next cell on the right in the Condition column.
  1. Use Shift+Tab to select a cell on the left.

  1. In the first row cell of the Condition column, enter the following text:
  1. This is an optional condition label that you include with the condition. Press Enter after the label to place the label and condition on separate lines.

    Condition 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 (_). In the generated code for a truth table, the condition label becomes the name of a temporary data variable that stores the outcome of its condition. If no label is entered, Stateflow names a temporary variable of its own.

  1. Press Enter and enter the following text:
  1. This is the actual condition. Each condition you enter must evaluate to zero (false) or nonzero (true). You can use optional brackets in the condition (for example, [x == 1]) as you would in Stateflow action language.

    You can use data passed to the truth table function through its arguments in truth table conditions. The preceding condition tests whether the argument x is equal to 1. You can also use data defined for parent objects of the truth table in Stateflow, including the Stateflow diagram.

  1. Use the preceding steps to enter the remaining two conditions, as shown in the following:


Previous page  Opening a Truth Table for Editing Entering Truth Table Decisions Next page

© 1994-2005 The MathWorks, Inc.