|On this page…|
Once you completely specify your truth tables, you begin the process of debugging them. The first step is to run diagnostics to check truth tables for syntax errors including overspecification and underspecification, as described in Correct Overspecified and Underspecified Truth Tables.
To check for syntax errors:
Double-click the truth table to open its editor.
If there are no errors or warnings, a message of success appears. If errors exist, you see a window with diagnostic messages. For example, if you change the action for decision column D4 to an action that does not exist, you get the following messages:
Each error appears with a red button, and each warning appears with a gray button. The first error message appears highlighted in the top pane, and the diagnostic message appears in the bottom pane.
Truth table diagnostics run automatically when you start simulation of the model with a new or modified truth table. If no errors exist, the diagnostic window does not appear and simulation starts immediately.
Ways to debug truth tables during simulation include:
|Method||Type of Truth Tables||How To Do It|
|Use Stateflow® debugging tools to step through each condition and action, and monitor data values during simulation.||C truth table and MATLAB® truth table||See Use Stateflow Debugging Tools.|
|Use MATLAB debugging tools to step through generated code for the truth table.||MATLAB truth table only||See Use MATLAB Debugging Tools.|
When you use Stateflow debugging tools to debug truth tables, you must perform these tasks:
Specify a Breakpoint for the Call to a Truth Table. Before you debug the truth table during simulation, you must set a breakpoint for the truth table. This breakpoint pauses execution during simulation so that you can debug each execution step of a truth table using the Stateflow Debugger.
A breakpoint occurs when the chart calls this truth table function during simulation.
Note: You can also set breakpoints using the Truth Table properties dialog box. However, using the right-click context menu is faster. For more information, see Set Breakpoints to Debug Charts.
Enter sfdebugger at the command prompt to open the Stateflow Debugging window.
If you made any changes to the truth tables since the last simulation, the debugger checks automatically for syntax errors. If you receive errors or warnings, make corrections before you try to simulate again.
If no syntax errors exist in the truth table, simulation of your model begins.
When this breakpoint occurs, the Truth Table Editor appears and the Start button in the Stateflow Debugging window changes to Continue.
An updated display appears in the bottom pane.
You can use this display to monitor Stateflow data during simulation.
The INIT action of the truth table highlights prior to execution.
Because the first decision is true, truth table execution advances to its action A1.
This step executes the final action and exits the truth table. The Display block in the model displays the number 1.
MATLAB truth tables generate content as MATLAB code, a format that offers advantages for debugging. You can set breakpoints on any line of generated code (whereas you cannot set breakpoints directly on a truth table). You can debug code that MATLAB truth tables generate the same way you debug a MATLAB function.
For more information about how to generate content for truth tables, see How Stateflow Generates Content for Truth Tables.