Main Content

State Transition Tables in Stateflow

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.

Benefits of using state transition tables include:

  • Ease of modeling train-like state machines, where the modal logic involves transitions from one state to its neighbor

  • Concise, compact format for a state machine

  • Reduced maintenance of graphical objects

  • When you add or remove states from a chart, you have to rearrange states, transitions, and junctions. When you add or remove states from a state transition table, you do not have to rearrange any graphical objects.

State transition tables support using both MATLAB® and C as the action language. For more information about the differences between these action languages, see Differences Between MATLAB and C as Action Language Syntax.

Use a State Transition Chart to Model a Boiler

The following state transition table contains the modal logic for maintaining the temperature of a boiler between two set points:

This Stateflow chart represents the same modal logic:

Rules for Using State Transition Tables

  • If you specify an action in a transition cell, it must be a condition action.

  • State transition tables must have at least one state row and one transition column.

Differences Between State Transition Tables and Charts

State transition tables support a subset of the most commonly used elements in Stateflow charts. Elements that state transition tables do not support include:

  • Supertransitions

  • Parallel (AND) decomposition

  • Local events

  • Flow charts

  • Use of chart-level functions (graphical, truth table, MATLAB, and Simulink)

Anatomy of a State Transition Table

A state transition table contains the following components:

Each transition column contains the following state-to-state transition information:

  • Condition

  • Condition action

  • Destination state

Create State Transition Table and Specify Properties

How to Create a New State Transition Table

At the MATLAB command prompt, enter:


From the Simulink Library Browser:

  1. Select the Stateflow library.

  2. Drag a state transition table into your model.

Properties for State Transition Tables

To access properties, in the Stateflow Editor, in the Modeling tab, click Table Properties.

These properties are the same as those for charts that use MATLAB as the action language. For a description of each property, see Specify Properties for Stateflow Charts.

Generate Diagrams from State Transition Tables

Stateflow software automatically generates a read-only state transition diagram from the state transition table you create. As you enter changes to a state transition table, Stateflow incrementally updates the diagram as well. To see the most up-to-date version of the underlying diagram, in the Debug tab, click Show Auto Chart.

See Also

Related Topics