| Contents | Index |
| On this page… |
|---|
Stateflow Classic Truth Tables |
Using Stateflow Classic truth tables, you can specify conditions and actions using the Stateflow action language, which supports basic C constructs and provides access to MATLAB functions using the ml namespace operator or ml function. For more information about the Stateflow action language, see Using Actions in Stateflow Charts.
Stateflow Classic mode is the default setting for Stateflow truth tables.
You can specify conditions and actions for MATLAB truth tables by using MATLAB action language, which provides optimizations for code generation.
MATLAB truth tables offer several advantages over Stateflow Classic truth tables:
The MATLAB action language provides a richer syntax for specifying control flow logic in truth table actions. It provides for loops, while loops, nested if statements, and switch statements.
You can call MATLAB functions directly in truth table actions. Also, you can call library functions (for example, MATLAB sin and fft functions) and generate code for these functions using Simulink Coder code generation software.
You can create temporary or persistent variables during simulation or in code directly without having to define them in the Model Explorer.
Better debugging tools are available. You can set breakpoints on lines of code, step through code, and watch data values using tool tips.
You can use persistent variables in truth table actions. This feature allows you to define data that persists across multiple calls to the truth table function during simulation.
To specify an action language for your Stateflow truth table:
Double-click the truth table to open the Truth Table Editor.
Select Language from the Settings menu.
Select a language from the drop-down menu.
When you migrate from a Stateflow Classic truth table to a MATLAB truth table, you must verify that the code used to program the actions conforms to MATLAB syntax. Between the two action languages, these differences exist.
| For this type of action language... | Indices are... | And the expression for not equal to is... |
|---|---|---|
| MATLAB | One-based | ~= |
| Stateflow | Zero-based | != |
You can check for syntax errors by using the Run Diagnostics command in the Truth Table Editor, as described in Checking Truth Tables for Errors.
![]() | Where to Use a Truth Table | Workflow for Using Truth Tables | ![]() |

Learn how engineers use Stateflow to model state machines in their Simulink models.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |