Hauptinhalt

Stateflow.StateTransitionTableCell

R2026b

Condition, action, and destination cell in a state transition table

Since R2026b

    Description

    Use Stateflow.StateTransitionTableCell objects to programmatically read and modify condition, action, and destination cells in a Stateflow® state transition table. A cell represents a single condition, condition action, and destination for one transition column in a row. For more information, see Model Finite State Machines Using State Transition Tables.

    Creation

    Description

    cells = stt.addTransitionColumn() appends a transition column to the state transition table stt and returns the cells in that column as an array of Stateflow.StateTransitionTableCell objects.

    example

    cells = getTransitionCell(row) returns an array of Stateflow.StateTransitionTableCell objects for the specified row. Each element corresponds to one transition column in the state transition table.

    example

    cells = stt.getTransitionColumn(columnName) returns the cells for the transition column with the specified column name as an array of Stateflow.StateTransitionTableCell objects.

    cells = stt.getTransitionColumn(index) returns the cells for the transition column at the specified numeric column index as an array of Stateflow.StateTransitionTableCell objects.

    cell = stt.getTransitionCell(rowIndex, columnIndex) returns the Stateflow.StateTransitionTableCell object at the specified row index and column index in the state transition table stt.

    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.

    Transition Logic

    Condition to evaluate for the transition, specified as a string scalar or character vector. When the condition evaluates to true, Stateflow executes the condition action and transitions to the destination state. For more information, see Conditions.

    Action to execute when the condition evaluates to true, specified as a string scalar or character vector. For more information, see Condition Actions.

    Name of the destination state for the transition, specified as a string scalar or character vector. When the condition evaluates to true, the chart transitions to the state with this name. In addition to a state name, the value accepts these special keywords:

    • $NEXT — Transition to the next sibling state.

    • $PREV — Transition to the previous sibling state.

    • $SELF — Create a self-loop transition.

    Setting Destination to $NEXT, $PREV, or $SELF on a default transition path row or an inner transition path row throws an error.

    Cell Identification

    This property is read-only.

    Header of the transition column containing the cell, returned as a string. For example, the first transition column has the header "IF" and subsequent columns have headers such as "ELSE-IF(2)", "ELSE-IF(3)", and so on.

    Object Functions

    getParentIdentify parent of object

    Examples

    collapse all

    Open a model that contains a state transition table and get a handle to the table.

    open_system("myModel")
    stt = find(sfroot, "-isa", "Stateflow.StateTransitionTableChart", ...
        "Name", "mySTT");

    Get the transition cells for a state row by using getRow and getTransitionCell.

    row = stt.getRow("Idle");
    cells = row.getTransitionCell();

    Set the condition, condition action, and destination for the first transition cell.

    cell = cells(1);
    cell.Condition = "x > 3";
    cell.Action = "x = 0;";
    cell.Destination = "Active";

    Add a transition column to the state transition table. The column appends to the right of the existing columns.

    newCells = stt.addTransitionColumn();

    Set the condition and destination for the cell in the first row of the new column.

    newCells(1).Condition = "y == 0";
    newCells(1).Destination = "Idle";

    Version History

    Introduced in R2026b

    expand all