Stateflow User's Guide Previous page   Next Page

Calling a Truth Table in a Stateflow Action

In Creating a Stateflow Truth Table, you create the truth table function ttable with the signature

Now you need to specify a call to the truth table function in the Stateflow diagram. Later, when the diagram executes during simulation, it calls the truth table.

You can call truth table functions from the actions of any state or transition. You can also call truth tables from other functions, including graphical functions and other truth tables. Also, if you export a truth table, you can call it from any Stateflow chart in the model.

Use the following steps to call the ttable function from the default transition of its own Stateflow diagram.

  1. Select the Default Transition button

    from the drawing toolbar.
  2. Move the cursor to a location left of the truth table function and notice that the cursor takes on the shape of a downward-pointing arrow.
  3. Click to place a default transition into a terminating junction.

  4. Click the question mark character (?) that appears on the highlighted default transition.
  1. A blinking cursor in a text field appears for entering the label of the default transition.

  1. Enter the text
  1. and click outside the transition label to finish editing it.

    You might want to adjust the label's position by clicking and dragging it to a new location. The finished Stateflow diagram should have the following appearance:

    The label on the default transition that you entered provides a condition action that calls the truth table with arguments and a return value. When Simulink triggers the Stateflow block during simulation, the default transition is taken and a call to the truth table ttable is made.

    The call to the truth table in Stateflow action language must match the truth table signature. This means that the type of the return value c must match the type of the signature return value z, and the type of the arguments a and b must match the type of the signature arguments x and y. You ensure this with a later step in this section when you create the data that you use in Stateflow.

  1. From the File menu, select Save to save the model.

Previous page  Creating a Stateflow Truth Table Creating Truth Table Data in Stateflow and Simulink Next page

© 1994-2005 The MathWorks, Inc.