Main Content

Stateflow.StateTransitionTableChart

Tabular representation of state machine for modal logic

    Description

    Use a Stateflow.StateTransitionTableChart object to represent 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 block 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.

    Creation

    To create a Stateflow.StateTransitionTableChart object, call the function sfnew with the -STT argument. For example, to create a State Transition Table block in a new Simulink® model called myModel, enter:

    sfnew -STT myModel

    Alternatively, you can add a new State Transition Table block to an existing model by using the function add_block (Simulink):

    add_block("sflib/State Transition Table", ...
        "myModel/State Transition Table")

    Then, to access the Stateflow.StateTransitionTableChart object, call the find function for the Simulink.Root object:

    table = find(sfroot,"-isa","Stateflow.StateTransitionTableChart", ...
        Path="myModel/State Transition Table");

    Properties

    expand all

    Stateflow API objects have properties that correspond to the values you set in the Stateflow Editor. To access or modify a property, use dot notation. To access or modify multiple properties for multiple API objects, use the get and set functions, respectively. For more information, see Modify Properties and Call Functions of Stateflow Objects.

    Content

    Name of the state transition table, specified as a string scalar or character vector.

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

    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.

    Whether the state transition table supports variable-size data, specified as a numeric or logical 1 (true) or 0 (false). For more information, see Declare Variable-Size Data in Stateflow Charts.

    Chart Initialization

    Whether to initialize the state configuration of the state transition table at time zero instead of at the first input event, specified as a numeric or logical 1 (true) or 0 (false). For more information, see Execution of a Chart at Initialization.

    Behavior of the states when a function-call input event reenables the state transition table, specified as one of these values:

    • "" — The state transition table does not contain function-call input events.

    • "held" — The state transition table maintains the most recent values of the states.

    • "reset" — The state transition table reverts to the initial conditions of the states.

    For more information, see Control States in Charts Enabled by Function-Call Input Events.

    Whether to initialize the output data every time the state transition table wakes up, specified as a numeric or logical 1 (true) or 0 (false). For more information, see Initialize outputs every time chart wakes up.

    Active State Output

    Whether to create an active state data output port for the state transition table, specified as a numeric or logical 1 (true) or 0 (false). For more information, see Monitor State Activity Through Active State Data.

    This property is read-only.

    Active state data object for the state transition table, specified as a Stateflow.Data object. This property applies only when the HasOutputData property for the state transition table is true.

    Name of the active state data object for the state transition table, specified as a string scalar or character vector. This property applies only when the HasOutputData property for the state transition table is true.

    Monitoring mode for the active state output data, specified as "ChildActivity" or "LeafStateActivity".

    Name of the enumerated data type for the active state data object for the state transition table, specified as a string scalar or character vector. For more information, see Enum Name.

    Whether to define the enumerated data type for the active state data output manually, specified as a numeric or logical 1 (true) or 0 (false). For more information, see Define State Activity Enumeration Type.

    Discrete and Continuous-Time Semantics

    Activation method for the state transition table, specified as "CONTINUOUS", "DISCRETE", or "INHERITED". For more information, see Update Method.

    Sample time for activating the state transition table, specified as a string scalar or character vector. This property applies only when the ChartUpdate property for the state transition table is "DISCRETE".

    Whether to enable zero-crossing detection on state transitions in the state transition table, specified as a numeric or logical 1 (true) or 0 (false). This property applies only when the ChartUpdate property for the state transition table is set to "CONTINUOUS". For more information, see Disable Zero-Crossing Detection.

    Super Step Semantics

    Whether to enable super step semantics for the state transition table, specified as a numeric or logical 1 (true) or 0 (false). For more information, see Super Step Semantics.

    Maximum number of transitions the state transition table can take in one super step, specified as an integer scalar. This property applies only when the EnableNonTerminalStates property for the state transition table is true.

    Behavior if a super step for the state transition table exceeds the maximum number of transitions specified in the NonTerminalMaxCounts property before reaching a stable state, specified as one of these values:

    • "Proceed" — The state transition table goes to sleep with the last active state configuration.

    • "Throw Error" — The state transition table generates an error.

    This property applies only when the EnableNonTerminalStates property for the state transition table is true.

    Integer and Fixed-Point Data

    Whether the data in the state transition table saturates on integer overflow, specified as a numeric or logical 1 (true) or 0 (false). When this property is disabled, the data in the state transition table wraps on integer overflow. For more information, see Handle Integer and Enumeration Overflow for Chart Data.

    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 property applies only when the ActionLanguage property of the state transition table is "MATLAB".

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

    • "Same as MATLAB Default" — Use the same fimath properties as the current default fimath object.

    • "Other:UserSpecified" — Use the InputFimath property to specify the default fimath object.

    This property applies only when the ActionLanguage property of the state transition table is "MATLAB".

    Default fimath object, specified as a string scalar or character vector. When the EmlDefaultFimath property for the state transition table is "Other:UserSpecified", you can use this property to:

    • Enter an expression that constructs a fimath object.

    • Enter the variable name for a fimath object in the MATLAB® or model workspace.

    This property applies only when the ActionLanguage property of the state transition table is "MATLAB".

    C Action Language

    Whether to use bit operations in state and transition actions in the state transition table, specified as a numeric or logical 1 (true) or 0 (false). This property applies only to state transition tables that use C as the action language. For more information, see Enable C-bit operations.

    Debugging

    Debugger properties for the state transition table, specified as a Stateflow.ChartDebug object with this property:

    • Breakpoints.OnEntry — Whether to set the On Chart Entry breakpoint, specified as a numeric or logical 1 (true) or 0 (false).

    For more information, see Set Breakpoints to Debug Charts.

    Example: table.Debug.Breakpoints.OnEntry = true;

    Graphical Appearance

    This property is read-only.

    Editor for the state transition table, specified as a Stateflow.Editor object. You can use this object to control the position, size, and magnification level of the Stateflow Editor window.

    Whether the Stateflow Editor window is displaying the state transition table, specified as a numeric or logical 1 (true) or 0 (false).

    Background color for the chart that is automatically generated for the state transition table, specified as a three-element numeric vector of the form [red green blue] that specifies the red, green, and blue values. Each element must be in the range between 0 and 1.

    Color for the states in the chart that is automatically generated for the state transition table, specified as a three-element numeric vector of the form [red green blue] that specifies the red, green, and blue values. Each element must be in the range between 0 and 1.

    Color for transitions in the chart that is automatically generated for the state transition table, specified as a three-element numeric vector of the form [red green blue] that specifies the red, green, and blue values. Each element must be in the range between 0 and 1.

    Color for junctions in the chart that is automatically generated for the state transition table, specified as a three-element numeric vector of the form [red green blue] that specifies the red, green, and blue values. Each element must be in the range between 0 and 1.

    Font for the state labels in the chart that is automatically generated for the state transition table, specified as a Stateflow.STTStateFont object with these properties:

    • Name — Font name, specified as a string scalar or character vector.

    • Angle — Font angle, specified as "NORMAL" or "ITALIC".

    • Weight — Font weight, specified as "NORMAL" or "BOLD".

    • Size — Default font size for new states, specified as a scalar.

    Example: table.StateFont.Name = "Arial";

    Example: table.StateFont.Angle = "ITALIC";

    Example: table.StateFont.Weight = "BOLD;

    Example: table.StateFont.Size = 8;

    Color for the state labels in the chart that is automatically generated for the state transition table, specified as a three-element numeric vector of the form [red green blue] that specifies the red, green, and blue values. Each element must be in the range between 0 and 1.

    Font for the transition labels in the chart that is automatically generated for the state transition table, specified as a Stateflow.STTTransFont object with these properties:

    • Name — Font name, specified as a string scalar or character vector.

    • Angle — Font angle, specified as "NORMAL" or "ITALIC".

    • Weight — Font weight, specified as "NORMAL" or "BOLD".

    • Size — Default font size for new transitions, specified as a scalar.

    Example: table.TransitionFont.Name = "Arial";

    Example: table.TransitionFont.Angle = "ITALIC";

    Example: table.TransitionFont.Weight = "BOLD";

    Example: table.TransitionFont.Size = 8;

    Color for the transition labels in the chart that is automatically generated for the state transition table, specified as a three-element numeric vector of the form [red green blue] that specifies the red, green, and blue values. Each element must be in the range between 0 and 1.

    Hierarchy

    This property is read-only.

    Machine that contains the state transition table, specified as a Stateflow.Machine object.

    This property is read-only.

    Location of the state transition table in the model hierarchy, specified as a character vector.

    Whether the state transition table has changed after being opened or saved, specified as a numeric or logical 1 (true) or 0 (false).

    Whether the state transition table is locked, specified as a numeric or logical 1 (true) or 0 (false). Enable this property to prevent changes in the state transition table.

    This property is read-only.

    Whether the state transition table is locked, specified as a numeric or logical 1 (true) or 0 (false). This property is equivalent to the property Locked, but is used internally to prevent changes in the state transition table during simulation.

    Identification

    Description for the state transition table, specified as a string scalar or character vector.

    Document link for the state transition table, specified as a string scalar or character vector.

    User-defined tag for the state transition table, specified as data of any type.

    This property is read-only.

    Unique identifier, specified as an integer scalar. Use this property to distinguish the state transition table from other objects in the model. The value of this property is reassigned every time you start a new MATLAB session and may be recycled after an object is deleted.

    Object Functions

    findIdentify specified objects in hierarchy
    getChildrenIdentify children of object
    dialogOpen properties dialog box
    viewDisplay object in editing environment
    exportAsStructExport contents of state transition table as structure array

    Examples

    collapse all

    Call the function sfnew with the -STT argument to open a new Simulink model that contains an empty State Transition Table block.

    sfnew -STT

    Access the Simulink.Root object by calling the sfroot function.

    rt = sfroot;

    Access the Stateflow.StateTransitionTableChart object by calling the find function for the Simulink.Root object.

    table = find(rt,"-isa","Stateflow.StateTransitionTableChart");

    Export the contents of the state transition table in Model Bang-Bang Controller by Using a State Transition Table as an array of structures. This state transition table contains two top-level states and three substates.

    Access Stateflow.StateTransitionTableChart for the state transition table.

    table = find(sfroot,"-isa","Stateflow.StateTransitionTableChart");

    Export the contents of the state transition table as an array of structures.

    structure = exportAsStruct(table)
    structure = 
    
      1×5 struct array with fields:
    
        rowText
        depth
        rowType
        isDefaultTransitionOwner
        isWhenState
        hasHistory
        isExpanded
        outlinedTransitionIdxs
        sfObjectInfo
        aslInfo
        decompositionInfo

    View the contents of a top-level state.

    structure(1)
    ans = 
    
      struct with fields:
    
                         rowText: {'Normal'  {3×1 cell}  {3×1 cell}}
                           depth: 1
                         rowType: 0
        isDefaultTransitionOwner: 1
                     isWhenState: 0
                      hasHistory: 0
                      isExpanded: 1
          outlinedTransitionIdxs: [0 0 0]
                    sfObjectInfo: [1×3 struct]
                         aslInfo: [1×1 struct]
               decompositionInfo: [1×1 struct]

    View the contents of a child state.

    structure(4)
    ans = 
    
      struct with fields:
    
                         rowText: {'On↵entry:↵boiler_cmd = 1;'  {3×1 cell}  {3×1 cell}}
                           depth: 2
                         rowType: 0
        isDefaultTransitionOwner: 0
                     isWhenState: 0
                      hasHistory: 0
                      isExpanded: 0
          outlinedTransitionIdxs: [0 0 0]
                    sfObjectInfo: [1×3 struct]
                         aslInfo: [1×1 struct]
               decompositionInfo: [1×1 struct]

    Version History

    Introduced in R2012b

    expand all