| Stateflow User's Guide | ![]() |
Creating Truth Table Data in Stateflow and Simulink
When you create a truth table with its own signature, you specify data for it in the form of a return value (t) and argument values (x, y, z). When you specify a call to a truth table, as you did in Calling a Truth Table in a Stateflow Action, you specify data that you pass to the return and argument values of the truth table (d, a, b, and c). Now you need to define this data for the Stateflow diagram in the following steps:
The Goto Explorer button is a convenience for accessing the Model Explorer from the truth table editor. Notice in the Model Hierarchy pane (left pane) that the node for the function ttable is highlighted and that the Contents pane (right pane) displays the inputs (x, y, z) and outputs (t) for ttable. By default, these data are defined as scalars of type double. If you want to redefine these data with a different array size and type, you do it in the Model Explorer. However, no changes are necessary for this example.
Notice also in the Model Hierarchy pane that the node above the function ttable is a node for the Stateflow block Chart. This is the name of the Stateflow diagram that contains the truth table ttable.
Chart contains no data in the Contents pane. You need to add the return and argument data used in calling ttable.
data.
This data matches argument x in type and size, but still needs a change in name and scope.
a and press Enter.
Local under the Scope column.
You should now see the new data a in the Contents pane as shown.
b and c with the scope Input, and data d with a scope of Output (short for Output to Simulink).
You should now see the following data in Stateflow Explorer:
The data a, b, c, and d match their counterparts x, y, z, and t in the truth table signature in size (scalar) and type (double), but have a source outside the Stateflow block. Notice that input ports for a, b, and c, and an output port for d appear for the Stateflow block in the Simulink model.
| Calling a Truth Table in a Stateflow Action | Programming a Truth Table | ![]() |
© 1994-2005 The MathWorks, Inc.