Main Content

State Transition Table

Represent modal logic in tabular format

  • State Transition Table block

Libraries:
Stateflow

Description

The State Transition Table block represents a finite state machine in tabular format. Instead of drawing states and transitions in a Stateflow® chart, you can use a state transition table to model a state machine in a concise, compact format that requires minimal maintenance of graphical objects. For more information, see Model Finite State Machines Using State Transition Tables.

To implement control logic, State Transition Table blocks can use MATLAB® or C as the action language. For more information, see Differences Between MATLAB and C as Action Language Syntax.

Examples

Ports

Input

expand all

When you create input data in the Stateflow state transition table using the Symbols pane, Stateflow creates a corresponding input port on the State Transition Table block.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point | enumerated | bus | string

Output

expand all

When you create output data in the Stateflow state transition table by using the Symbols pane, Stateflow creates a corresponding output port on the State Transition Table block.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point | enumerated | bus | string

Parameters

expand all

To edit block parameters interactively, use the Property Inspector. From the Simulink® Toolstrip, on the Simulation tab, in the Prepare gallery, select Property Inspector.

Note

State Transition Table blocks also have Subsystem (Simulink) block parameters that you can access by right-clicking the block and clicking Block Parameters (Subsystem). However, updating these block parameters is not recommended.

Method to update or wake up a Stateflow state transition table, specified as Inherited, Discrete, or Continuous.

Inherited

Input from the Simulink model determines when the state transition table wakes up during a simulation.

If you define input events for the state transition table, the signal from the Simulink block connected to the trigger port triggers the state transition table. The Simulink signal can be Rising, Falling, or Either (rising and falling), or in response to a Function Call. For more information, see Activate a Stateflow Chart by Sending Input Events.

If you do not define input events, the Stateflow state transition table implicitly inherits triggers from the Simulink model. These implicit events are the discrete or continuous sample times of the Simulink signals that provide inputs to the state transition table. If you define data inputs, the state transition table wakes at the rate of the fastest data input. If you do not define any data input for the state transition table, the state transition table wakes up as defined by the execution behavior of its parent subsystem.

Discrete

The Stateflow state transition table wakes when the Simulink model generates an implicit event at regular time intervals that you specify in the Sample Time state transition table property. Other blocks in the Simulink model can have different sample times.

Continuous

The Stateflow state transition table updates its state during major time steps only, and computes outputs and local continuous variables during major and minor time steps. The state transition table can register zero crossings, which allows Simulink models to sample Stateflow state transition tables whenever state changes occur. The Stateflow state transition table computes derivatives for local continuous variables. For more information, see Continuous-Time Modeling in Stateflow.

Programmatic Use

To set the block parameter value programmatically, access the Stateflow.StateTransitionTableChart object of the block and change the object property by using dot notation.

Parameter: ChartUpdate
Values: "INHERITED" (default) | "CONTINUOUS" | "DISCRETE"

The default time interval is -1, which indicates that the Stateflow state transition table inherits the sample time from Simulink.

Specify the time interval at which the state transition table wakes up during simulation. The default value indicates that the state transition table inherits the sample time from Simulink. For more information on specifying sample time, see Specify Sample Time (Simulink).

Do not use the Sample Time parameter in the Subsystem block parameters. Instead, use the Property Inspector.

Dependencies

To enable this parameter, set Update method to Discrete.

Programmatic Use

To set the block parameter value programmatically, access the Stateflow.StateTransitionTableChart object of the block and change the object property by using dot notation.

Parameter: SampleTime
Values: "-1" (default) | string scalar | character vector
Data Types: string | char

Whether to create an active state data output port for the state transition table. For more information, see Monitor State Activity Through Active State Data.

Programmatic Use

To set the block parameter value programmatically, access the Stateflow.StateTransitionTableChart object of the block and change the object property by using dot notation.

Parameter: HasOutputData
Values: false or 0 (default) | true or 1
Data Types: logical

Monitoring mode for the active state output data.

Dependencies

To enable this parameter, enable Create output for monitoring.

Programmatic Use

To set the block parameter value programmatically, access the Stateflow.StateTransitionTableChart object of the block and change the object property by using dot notation.

Parameter: OutputMonitoringMode
Values: "ChildActivity" (default) | "LeafStateActivity"

Name of the active state data object for the state transition table.

Dependencies

To enable this parameter, enable Create output for monitoring.

Programmatic Use

To set the block parameter value programmatically, access the Stateflow.StateTransitionTableChart object of the block and change the object property by using dot notation.

Parameter: OutputPortName
Values: "State_Transition_TableMode" (default) | string scalar | character vector
Data Types: string | char

Name of the active state data object for the state transition table.

Dependencies

To enable this parameter, enable Create output for monitoring.

Programmatic Use

To set the block parameter value programmatically, access the Stateflow.StateTransitionTableChart object of the block and change the object property by using dot notation.

Parameter: EnumTypeName
Values: "State_Transition_TableModeType" (default) | string scalar | character vector
Data Types: string | char

Whether to define the enumerated data type for the active state data output manually. For more information, see Define State Activity Enumeration Type.

Dependencies

To enable this parameter, enable Create output for monitoring.

Programmatic Use

To set the block parameter value programmatically, access the Stateflow.StateTransitionTableChart object of the block and change the object property by using dot notation.

Parameter: DoNotAutogenerateEnum
Values: false or 0 (default) | true or 1
Data Types: logical

Advanced

Whether to initialize the state configuration of the state transition table at time zero instead of at the first input event. For more information, see Execution of a Chart at Initialization.

Programmatic Use

To set the block parameter value programmatically, access the Stateflow.StateTransitionTableChart object of the block and change the object property by using dot notation.

Parameter: ExecuteAtInitialization
Values: false or 0 (default) | true or 1
Data Types: logical

Whether the data in the state transition table saturates on integer overflow. When you clear this parameter, the data in the state transition table wraps on integer overflow. For more information, see Handle Integer and Enumeration Overflow for Chart Data.

Programmatic Use

To set the block parameter value programmatically, access the Stateflow.StateTransitionTableChart object of the block and change the object property by using dot notation.

Parameter: SaturateOnIntegerOverflow
Values: true or 1 (default) | false or 0
Data Types: logical

Whether to initialize the output data every time the state transition table wakes up.

When you select this parameter, the state transition table resets its output values every time that the state transition table wakes up, not only at time 0. The state transition table resets the output values whenever function call, edge trigger, or clock tick triggers the state transition table. If you set an initial value for an output data object, the output resets to that value. Otherwise, the output resets to zero. Select this parameter to:

  • Ensure that all outputs are defined in every state transition table execution.

  • Prevent latching of outputs, that is, prevent values of outputs computed in previous executions.

  • Provide all state transition table outputs with a meaningful initial value.

For more information, see Initial value.

Programmatic Use

To set the block parameter value programmatically, access the Stateflow.StateTransitionTableChart object of the block and change the object property by using dot notation.

Parameter: InitializeOutput
Values: false or 0 (default) | true or 1
Data Types: logical

Whether the state transition table supports variable-size data. For more information, see Declare Variable-Size Data in Stateflow Charts.

Programmatic Use

To set the block parameter value programmatically, access the Stateflow.StateTransitionTableChart object of the block and change the object property by using dot notation.

Parameter: SupportVariableSizing
Values: true or 1 (default) | false or 0
Data Types: logical

Whether to enable super step semantics for the state transition table. Select this parameter to enable the state transition table to take multiple transitions in each time step until it reaches a stable state. This option is not available when you. For more information, see Super Step Semantics.

Dependencies

To enable this parameter, set Update method to Discrete.

Programmatic Use

To set the block parameter value programmatically, access the Stateflow.StateTransitionTableChart object of the block and change the object property by using dot notation.

Parameter: EnableNonTerminalStates
Values: false or 0 (default) | true or 1
Data Types: logical

The maximum number of transitions that can be completed in one super step. For more information, see Super Step Semantics.

Dependencies

To enable this parameter, enable Enable super step semantics.

Programmatic Use

To set the block parameter value programmatically, access the Stateflow.StateTransitionTableChart object of the block and change the object property by using dot notation.

Parameter: NonTerminalMaxCounts
Values: 1000 (default) | positive integer
Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Action for Stateflow to take if super step exceeds maximum number of transitions in one super step. For more information, see Super Step Semantics.

Dependencies

To enable this parameter, enable Enable super step semantics.

Programmatic Use

To set the block parameter value programmatically, access the Stateflow.StateTransitionTableChart object of the block and change the object property by using dot notation.

Parameter: NonTerminalUnstableBehavior
Values: "Proceed" (default) | "Throw Error"

Since R2023a

Whether the state transition table treats output data with a dimension of length 1 as fixed size. When you select this parameter, the state transition table treats output data that have at least one dimension of length 1 as fixed size, regardless of whether you enable the Variable size data property. When you clear this parameter, the state transition table treats data with the Variable size property enabled as variable size.

Programmatic Use

To set the block parameter value programmatically, access the Stateflow.StateTransitionTableChart object of the block and change the object property by using dot notation.

Parameter: TreatDimensionOfLengthOneAsFixedSize
Values: true or 1 (default) | false or 0
Data Types: logical

Action language to use to program the state transition table, specified as MATLAB or C. For more information, see Differences Between MATLAB and C as Action Language Syntax.

Programmatic Use

To set the block parameter value programmatically, access the Stateflow.StateTransitionTableChart object of the block and change the object property by using dot notation.

Parameter: ActionLanguage
Values: "MATLAB" (default) | "C"

State machine semantics implemented by the state transition table, specified as Classic, Mealy, or Moore. For more information, see Overview of Mealy and Moore Machines.

Programmatic Use

To set the block parameter value programmatically, access the Stateflow.StateTransitionTableChart object of the block and change the object property by using dot notation.

Parameter: StateMachineType
Values: "Classic" (default) | "Mealy" | "Moore"

Fixed-point properties

Inherited Simulink signals to treat as Fixed-Point Designer™ fi objects, specified as one of these values:

  • Fixed-point — The state transition table treats all fixed-point inputs as fi objects.

  • Fixed-point & Integer — The state transition table treats all fixed-point and integer inputs as fi objects.

This parameter applies only to state transition tables that use MATLAB as the action language.

Programmatic Use

To set the block parameter value programmatically, access the Stateflow.StateTransitionTableChart object of the block and change the object property by using dot notation.

Parameter: TreatAsFi
Values: "Fixed-point" (default) | "Fixed-point & Integer"

Default fimath object properties for the state transition table, specified as one of these values:

  • Same as MATLAB — The state transition table uses the same fimath object properties as the current default fimath object. The text box is dimmed and displays the current global fimath object in read-only form.

  • Specify other — Specify your own fimath object in the text box.

For more information, see fimath Object Construction (Fixed-Point Designer).

Dependencies

To enable this parameter, set Action language to MATLAB.

Programmatic Use

To set the block parameter value programmatically, access the Stateflow.StateTransitionTableChart object of the block and change the object property by using dot notation.

Parameter: EmlDefaultFimath
Values: "Same as MATLAB Default" (default) | "Other:UserSpecified"

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

PLC Code Generation
Generate Structured Text code using Simulink® PLC Coder™.

Fixed-Point Conversion
Design and simulate fixed-point systems using Fixed-Point Designer™.

Version History

Introduced in R2012b

expand all