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.
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:
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.
State transition tables support a subset of the most commonly used elements in Stateflow charts. Elements that state transition tables do not support include:
Parallel (AND) decomposition
Use of chart-level functions (graphical, truth table, MATLAB, and Simulink)
A state transition table contains the following components:
Each transition column contains the following state-to-state transition information:
At the MATLAB command prompt, enter:
From the Simulink Library Browser:
Select the Stateflow library.
Drag a state transition table into your model.
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.
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.