State Transition Table Operations

A state transition table is an alternative way of expressing sequential modal logic. Instead of drawing states and transitions graphically in a Stateflow® chart, use state transition tables to express the modal logic in tabular format. State transition tables are supported only as blocks in a Simulink® model. For more information, see State Transition Tables in Stateflow.

To create state transition tables, use the Stateflow Editor. You can insert, edit, and move rows and columns. You can also add history junctions and set the default state for the state transition table.

Insert Rows and Columns

To insert a row:

  1. Select an existing state.

  2. In the Modeling tab, select one of the following options:

    OptionDescription
    Insert State RowInserts a state at the same level of hierarchy.
    Insert Child State RowInserts a state as a child of the selected state.
    Insert Default Transition Path RowInserts a row for specifying conditional default transition paths.
    Insert Inner Transition Path RowInserts a row for specifying inner transitions from the selected parent state to its child states. This row type can only be added to states with children states.

To insert a column:

  1. In the Modeling tab, click Append Transition Col. A new else-if column appears to the right of the last column.

Move Rows and Cells

To move a row, click the state cell and drag the row to a new location. As you drag the row, you see a visual indicator of where in the hierarchy the state will appear in its new position.

To move a transition cell, click anywhere in the cell and drag the condition, action, and destination cells as a unit to a new location. The transition cell you displace moves one cell to the right. If column does not exist, Stateflow creates one. The state transition table prevents you from moving cells to an invalid destination and alerts you to the problem.

Copy Rows and Transition Cells

To copy a row:

  1. Right-click the state in the row you want to copy and select Copy.

  2. Right-click the state in the destination row and select Paste.

    The row appears above the destination row.

To copy a transition cell:

  1. Right-click a cell and select Copy.

  2. Right-click a destination cell of the same type and select Paste.

    The new content overwrites the existing content at the destination. The state transition table prevents you from copying content to an invalid destination.

Set Default State

Right-click the state and select Set to default.

Add History Junction

You can add history junctions to states that have children. Right-click the state and select Add history junction.

Print State Transition Tables

To print a copy of the state transition table, press Ctrl+P (Command+P).

Select and Clear Table Elements

TaskAction
Select a cell for editingClick the cell.
Exit edit mode in a cellPress Esc or click another table, cell, row, or column.

Undo and Redo Edit Operations

To undo the effects of the previous operation, press Ctrl+Z (Command+Z).

To redo the effects of the previous operation, press Ctrl+Y (Command+Y).

You can undo and redo up to 10 operations.

Related Topics