Main Content

View Sequential Logic Through State Transition Matrix

This example shows how to use the State Transition Matrix view for a state transition table in Stateflow®. 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.

Generate State Transition Matrix

A state transition matrix is an alternative, read-only view of a State Transition Table. This view enables you to analyze how the state transition table responds to various input conditions. For example, this state transition table models debouncing logic that is commonly used to remove jitter in switching logic. The debouncer removes rapid changes in the input u that last less than 0.1 seconds.

To generate the state transition matrix view, on the Debug tab, click Transition Matrix.

Each row of the matrix represents a state in the state transition table. These states appear on the left of the matrix in the same order as in the state transition table.

The columns of the matrix correspond to conditions or events. Every unique condition or event used in the state transition table is represented by a separate column. The order of the columns is based on the number of states that respond to each condition or event. Conditions on the left of the matrix impact more states than conditions on the right of the matrix.

The cells in the matrix display how the chart responds to a particular condition or event when a state is active. If a condition or event does not impact a state, the corresponding cell of the matrix appears empty. Empty cells to the left of a nonempty entry appear in light gray. Empty cells to the right of the last nonempty entry in a row appear in dark gray.

If you change the state transition table, you must regenerate the state transition matrix.

Examine State Reactions

To see the reaction of a state to each event or condition, look at all the entries in a state row. To see how each state responds to an event or condition, look at all the entries in a column.

Each entry in the matrix lists the action and destination for a transition in the state transition table. The execution order of the transition appears in the upper-right corner of each entry. The execution order is displayed in red if it is out of order relative to the matrix columns. Otherwise, the execution order is displayed in blue.

Filter by State Name

To see a subset of state rows, you can filter rows based on state names. In the upper-left corner of the state transition matrix, in the Filter States search box, enter a state name or select a name from the drop-down list.

Trace Matrix Cells to State Transition Table

In the state transition matrix, the state names, conditions, actions, and destinations are hyperlinks. To highlight the corresponding state, action, condition, or destination in the state transition table, click one of these hyperlinks.

Related Topics