| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Stateflow |
| Contents | Index |
| Learn more about Stateflow |
| On this page… |
|---|
Stateflow Classic Truth Tables Selecting a Language for Stateflow Truth Tables Migration from Stateflow Classic to Embedded MATLAB 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 Embedded MATLAB truth tables by using Embedded MATLAB action language, a restricted subset of the MATLAB language that provides optimizations for code generation.
Embedded MATLAB truth tables offer several advantages over Stateflow Classic truth tables:
The Embedded MATLAB language subset 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 Embedded MATLAB library functions (for example MATLAB sin and fft functions) and generate code for these functions using Real-Time Workshop 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.
Embedded MATLAB language subset uses a better debugging scheme. It is easier to set breakpoints on lines of code, step through code, and watch data values through 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.
You get more comprehensive model coverage. Embedded MATLAB truth tables generate coverage reports on branches in conditions and actions. Stateflow Classic truth tables provide coverage reports for conditions only. For more information, see Checking Model Coverage for Truth Tables.
To specify an action language for your Stateflow truth table, follow these steps:
Double-click the truth table to open the Truth Table Editor.
Select Language from the Settings menu.
Choose a language from the drop-down menu.
When you migrate from a Stateflow Classic truth table to an Embedded MATLAB truth table, you must verify that the code used to program the actions conforms to Embedded 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... |
|---|---|---|
| Embedded 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.
![]() | What Is a Truth Table? | Workflow for Using Truth Tables | ![]() |

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 |