Stateflow User's Guide Previous page   Next Page

How Stateflow Generates Graphical Functions for Truth Tables

This topic shows you through an example how the logic of a truth table translates into a graphical function. See Viewing the Graphical Function for a Truth Table to find out how to access the generated graphical function.

The following example truth table has three conditions, four decisions and actions, and initial and final actions:

Stateflow generates the following graphical function for the preceding truth table:

Stateflow uses the top half of the generated function to do the following:

The following generated flow diagram for the check_temp truth table shows this process, which includes number steps to show the order of execution:

The stored values for the conditions are used in the bottom half of the function to make decisions on which action to perform. The following shows the remaining half of the generated function, along with numbered steps for showing the order of consideration for each condition and action:

Each decision is implemented as a fork from a connective junction with one of two possible paths:

The preceding implementation continues from the first decision through the remaining decisions in left to right column order. When a specified decision is matched, the action specified for that decision is executed as a condition action of its transition segment. Once the action is performed, the flow diagram performs the final action for the truth table and terminates. This means that only one action results from a call to a truth table graphical function. This also implies that no data dependencies are possible between different decisions.

When you start constructing your own truth tables, you will need to troubleshoot them. When you simulate your model, Stateflow checks your truth tables for errors. Once you finish building a truth table and eliminate all detectable errors from it, you can debug it during simulation.

Stateflow also provides another type of debugging that is useful in making sure that your truth table conditions, decisions, and actions are completely tested. This type of debugging is referred to as model coverage. The Model Coverage tool reports on model coverage for Stateflow diagrams and their objects. See Model Coverage for Truth Tables for a description and example of truth table model coverage.

Finally, Stateflow realizes truth tables by generating a graphical function with the logical behavior you specify. To see how Stateflow generates these graphical functions, see How Stateflow Realizes Truth Tables.


Previous page  Viewing the Graphical Function for a Truth Table Using Embedded MATLAB Functions Next page

© 1994-2005 The MathWorks, Inc.