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 for sequential modal logic 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 Use State Transition Tables to Express Sequential Logic in Tabular Form.

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.

State Transition Table block properties specify how your state transition table interfaces with the Simulink® model. You can modify these properties in the Property Inspector, the Model Explorer, or the State Transition Table properties dialog box. For more information, see Specify Properties for State Transition Tables. Alternatively, you can specify state transition table properties programmatically by using Stateflow.StateTransitionTableChart objects. For more information about the Stateflow programmatic interface, see Overview of the Stateflow API.

Ports

Input

expand all

When you create input data in the Symbols pane, Stateflow creates input ports. The input data that you create has a corresponding input port that appears once you create data.

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 Symbols pane, Stateflow creates output ports. The output data that you create has a corresponding output port that appears once you create data.

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

Parameters

expand all

Parameters on the Code Generation tab require Simulink Coder™ or Embedded Coder®.

Main

Select how to display port labels on the State Transition Table block icon.

none

Do not display port labels.

FromPortIcon

If the corresponding port icon displays a signal name, display the signal name on the State Transition Table block. Otherwise, display the port block name.

FromPortBlockName

Display the name of the corresponding port block on the State Transition Table block.

SignalName

If a signal name exists, display the name of the signal connected to the port on the State Transition Table block. Otherwise, display the name of the corresponding port block.

Programmatic Use

Parameter: ShowPortLabels
Type: string scalar or character vector
Value: "none""FromPortIcon" | "FromPortBlockName" | "SignalName"
Default: "FromPortIcon"

Control user access to the contents of the chart.

ReadWrite

Enable opening and modification of chart contents.

ReadOnly

Enable opening but not modification of the chart. If the chart resides in a block library, you can create and open links to the chart and can make and modify local copies of the chart but you cannot change the permissions or modify the contents of the original library instance.

NoReadOrWrite

Disable opening or modification of chart. If the chart resides in a library, you can create links to the chart in a model but you cannot open, modify, change permissions, or create local copies of the chart.

Programmatic Use

Parameter: Permissions
Type: string scalar or character vector
Value: "ReadWrite" | "ReadOnly" | "NoReadOrWrite"
Default: "ReadWrite"
off

Do not try to eliminate any artificial algebraic loops that include the atomic subchart.

on

Try to eliminate any artificial algebraic loops that include the atomic subchart.

Programmatic Use

Parameter: MinAlgLoopOccurrences
Type: string scalar or character vector
Value: "off" | "on"
Default: "off"

Specify whether all blocks in this chart must run at the same rate or can run at different rates.

  • If the blocks in the chart can run at different rates, specify the chart sample time as inherited (-1).

  • If all blocks must run at the same rate, specify the sample time corresponding to this rate as the value of the Sample time parameter.

  • If any of the blocks in the chart specify a different sample time (other than -1 or inf), Simulink displays an error message when you update or simulate the model. For example, suppose all the blocks in the chart must run 5 times a second. To ensure this time, specify the sample time of the chart as 0.2. In this example, if any of the blocks in the chart specify a sample time other than 0.2, -1, or inf, Simulink displays an error when you update or simulate the model.

-1

Specify inherited sample time. If the blocks in the chart can run at different rates, use this sample time.

[Ts 0]

Specify periodic sample time.

Programmatic Use

Parameter: SystemSampleTime
Type: string scalar or character vector
Value: "-1" | "[Ts 0]"
Default: "-1"

Code Generation

Select the generated code format for an atomic (nonvirtual) subchart.

Auto

Simulink Coder chooses the optimal format for your system based on the type and number of instances of the chart that exist in the model.

Inline

Simulink Coder inlines the chart unconditionally.

Nonreusable function

Simulink Coder explicitly generates a separate function in a separate file. State transition tables with this setting generate functions that might have arguments depending on the Function interface (Simulink) parameter setting. You can name the generated function and file using parameters Function name (Simulink) and File name (no extension) (Simulink) respectively. These functions are not reentrant.

Reusable function

Simulink Coder generates a function with arguments that allows reuse of chart code when a model includes multiple instances of the chart.

This option generates a function with arguments that allows chart code to be reused in the generated code of a model reference hierarchy that includes multiple instances of a chart across referenced models. In this case, the chart must be in a library.

Tips

  • When you want multiple instances of a chart represented as one reusable function, you can designate each one of them as Auto or as Reusable function. It is best to use one because using both creates two reusable functions, one for each designation. The outcomes of these choices differ only when reuse is not possible. Selecting Auto does not allow for control of the function or file name for the chart code.

  • The Reusable function and Auto options both determine whether multiple instances of a chart exist and the code can be reused. The options behave differently when it is impossible to reuse the code. In this case, Auto yields inlined code, or if circumstances prohibit inlining, separate functions for each chart instance.

  • If you select the Reusable function while your generated code is under source control, set File name options to Use subsystem name, Use function name, or User specified. Otherwise, the names of your code files change whenever you modify your model, which prevents source control on your files.

Dependency

  • This parameter requires Simulink Coder.

  • Setting this parameter to Nonreusable function or Reusable function enables the following parameters:

    • Function name options

    • File name options

    • Memory section for initialize/terminate functions (requires Embedded Coder and an ERT-based system target file)

    • Memory section for execution functions (requires Embedded Coder and an ERT-based system target file)

  • Setting this parameter to Nonreusable function enables Function with separate data (requires a license for Embedded Coder and an ERT-based system target file).

Programmatic Use

Parameter: RTWSystemCode
Type: string scalar or character vector
Value: "Auto" | "Inline" | "Nonreusable function" | "Reusable function"
Default: "Auto"

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