Truth tables implement combinatorial logic design in a concise, tabular format. Truth tables are supported only in Stateflow® blocks in a Simulink® model. For more information, see Reuse Combinatorial Logic by Defining Truth Tables.
To create truth tables, use the Stateflow Editor. You can insert, edit, and move rows and columns. You can also diagnose the truth table for syntax errors and view the auto-generated code for the truth table.
Append Column adds a column on the right end of the selected table.
Append Row adds a row to the bottom of the selected table.
Run Diagnostics checks the truth table for syntax errors. See Debug Run-Time Errors in a Truth Table.
View Auto-generated Content displays the code generated for the truth table. C truth tables generate graphical functions. MATLAB® truth tables generate MATLAB code. For details, see View Generated Content for Stateflow Truth Tables.
The default Condition Table and the default Action Table have one empty row. Click a cell to edit its text contents. To move horizontally between cells, use the up and down arrow keys.
To display only one of the two tables, double-click the header of the table that you want to display. To revert to the display of both tables, double-click the header of the displayed table.
Cells for the numbered rows in decision columns like D1 can take
-. After you
select one of these cells, you can use the space bar to step through the
- values. In these cells
you can use the left, right, up, and down arrow keys to advance to another cell in any
To move a condition or action row up or down:
To select the row, click the row header.
Drag the row to a new position.
The truth table renumbers the rows.
To move a decision column left or right:
To select the column, click the column header .
Drag the column to a new position.
The truth table renumbers the decision columns.
To select multiple rows or columns that you want to move, hold down the Ctrl key.
|Select a cell for editing||Click the cell|
|Select text in a cell||Click and drag your pointer over the text|
|Select a row||Click the header for the row|
|Select a decision column in the Condition Table||Click the header for the column|
|Deselect a selected cell, row, or column||Click outside of the Condition Table or Action Table.|
To undo the effects of the preceding operation, press Ctrl+Z (Command+Z).
To redo the effects of the preceding operation, press Ctrl+Y (Command+Y).
To zoom in on a truth table, press Ctrl++ (Command++).
To zoom out on a truth table, press Ctrl+- (Command+-).
To return to normal view (100%) on a truth table, press Ctrl+0 (Command+0).
To navigate to the Stateflow chart for the truth table, press the Esc key.