Products & Services Solutions Academia Support User Community Company

Learn more about Stateflow   

How Stateflow Software Implements Truth Tables

Types of Generated Content

Stateflow software realizes the logical behavior specified in a truth table by generating content as follows:

Type of Truth TableGenerated Content
Stateflow ClassicGraphical function
Embedded MATLABEmbedded MATLAB code

Viewing Generated Content

You generate content for a truth table when you simulate your model. Content regenerates whenever a truth table changes. To view the generated content of a truth table, follow these steps:

  1. Simulate the model that contains the truth table.

  2. Double-click the truth table to open its editor.

  3. Select the View Generated Content button.

How Stateflow Software Generates Graphical Functions for Truth Tables

This section describes how Stateflow software translates the logic of a Stateflow Classic truth table into a graphical function.

In this example, a Stateflow Classic truth table has three conditions, four decisions and actions, and initial and final actions.

Stateflow software generates a graphical function for the preceding truth table. The top half of the flow graph is as follows, where the numbered steps show the order of execution.

The top half of the flow graph executes as follows:

The bottom half of the flow graph is as follows, where the numbered steps show the order of execution for each condition and action.

In the bottom half of the flow graph, the stored values for conditions determine which decision is true and what action to perform. Each decision appears as a fork from a connective junction with one of two possible paths:

This implementation continues from the first decision through the remaining decisions in left-to-right column order. When a decision match occurs, the action for that decision executes as a condition action of its transition segment. After the action executes, the flow graph performs the final action for the truth table and terminates. Therefore, only one action results from a call to a truth table graphical function. This behavior also means that no data dependencies are possible between different decisions.

How Stateflow Software Generates Embedded MATLAB Code for Truth Tables

Stateflow software generates the content of Embedded MATLAB truth tables as Embedded MATLAB code that represents each action as a nested function inside the main truth table function.

Nested functions offer these advantages over subfunctions:

The generated content appears in the Embedded MATLAB Editor, which provides tools for simulation and debugging, as described in Debugging an Embedded MATLAB Function Block.

Here is the generated content for the Embedded MATLAB truth table described in Programming Actions in Embedded MATLAB Action Language:

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS