Main Content

Stateflow.StateTransitionTableRow

R2026b

Row in a state transition table

Since R2026b

    Description

    Use Stateflow.StateTransitionTableRow objects to programmatically read and modify rows in a Stateflow® state transition table. A row represents a state, a default transition path, or an inner transition path in the table. For more information, see Model Finite State Machines Using State Transition Tables.

    Creation

    Description

    row = stt.addStateRow() creates a Stateflow.StateTransitionTableRow object by adding a state row to the state transition table stt and returning the new row.

    example

    row = stt.addDefaultTransitionPathRow() creates a Stateflow.StateTransitionTableRow object by adding a default transition path row to the state transition table stt and returning the new row.

    example

    row = parentRow.addChildStateRow() creates a Stateflow.StateTransitionTableRow object by adding a child state row to an existing row parentRow and returning the new row.

    example

    row = existingRow.addStateRowBelow() creates a Stateflow.StateTransitionTableRow object by adding a state row at the same level as the existing row existingRow and returning the new row.

    example

    row = parentRow.addInnerTransitionPathRow() creates a Stateflow.StateTransitionTableRow object by adding an inner transition path row to the existing row parentRow and returning the new row.

    example

    row = parentRow.addDefaultTransitionPathRow() creates a Stateflow.StateTransitionTableRow object by adding a default transition path row to the existing row parentRow and returning the new row. This clears all default transitions at the current level.

    example

    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.

    Row Identification

    This property is read-only.

    Type of row, returned as a string. The value is one of these options:

    • "state" — The row represents a state.

    • "default-transition" — The row represents a default transition path.

    • "inner-transition" — The row represents an inner transition path.

    Note

    The exportAsStruct function returns a rowType structure field that uses numeric values to represent the same row type information.

    Name of the state, specified as a string scalar or character vector. This property applies only to state rows.

    Full label string of the state, specified as a string scalar or character vector. The label string encodes the state name and all associated actions. Setting this property updates the EntryAction, DuringAction, ExitAction, and OnAction properties accordingly.

    State Actions

    This property is read-only.

    Entry action of the state, returned as a character vector. To set the entry action, update the LabelString property by using the en: prefix in the label string. This property applies only to state rows.

    This property is read-only.

    During action of the state, returned as a character vector. To set the during action, update the LabelString property by using the du: prefix in the label string. This property applies only to state rows.

    This property is read-only.

    Exit action of the state, returned as a character vector. To set the exit action, update the LabelString property by using the ex: prefix in the label string. This property applies only to state rows.

    This property is read-only.

    On action of the state, returned as a character vector. To set the on action, update the LabelString property by using the on event_name: prefix in the label string (for example, "on ev: x = 0;"). This property applies only to state rows.

    Hierarchy

    Decomposition type of the state, specified as a string scalar or character vector. The value is one of these options:

    • "EXCLUSIVE_OR" — Child states are mutually exclusive. Only one child state is active at a time.

    • "PARALLEL_AND" — Child states are active simultaneously.

    Setting this property updates the decomposition type in the state transition table UI and the underlying chart. This property applies only to state rows. For more information, see Define Exclusive and Parallel Modes by Using State Decomposition.

    Whether the state is the target of the default transition, specified as a numeric or logical 1 (true) or 0 (false). Setting this property to true marks the state as the default state at its level of the hierarchy. This property applies only to state rows.

    Setting this property throws an error in these cases:

    • The row is a default transition path row or an inner transition path row and the value is true.

    • The row is the only child state at its level and the value is false.

    • The parent row already has a default transition path row and the value is true.

    • The parent row uses parallel decomposition and the value is true.

    This property is read-only.

    Default transition path row for the state, returned as a Stateflow.StateTransitionTableRow object. If the state does not have a default transition path row, this property returns an empty array. This property applies only to state rows.

    This property is read-only.

    Inner transition path row for the state, returned as a Stateflow.StateTransitionTableRow object. If the state does not have an inner transition path row, this property returns an empty array. This property applies only to state rows.

    Whether the state has a history junction, specified as a numeric or logical 1 (true) or 0 (false). Setting this property to true adds a history junction to the state. A history junction causes the state to re-enter the last active child state rather than the default child state. This property applies only to state rows. For more information, see Resume Prior Substate Activity by Using History Junctions.

    Object Functions

    addChildStateRowAdd child state row to state transition table row
    addStateRowBelowAdd sibling state row below existing row in state transition table
    addInnerTransitionPathRowAdd inner transition path row to state transition table row
    addDefaultTransitionPathRowAdd default transition path row to state transition table
    getRowGet state row by name from state transition table or parent row
    getRowsGet all rows from state transition table or parent row
    getDefaultStateGet default state row from state transition table or parent row
    getParentIdentify parent of object
    getTransitionCellGet transition cell at specified row and column index in state transition table
    deleteRowDelete row from state transition table
    findIdentify specified objects in hierarchy

    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");

    Add a state row to the table. The new row appends to the end of the table.

    row = stt.addStateRow();
    row.Name = "Idle";

    Add a label string that defines an entry action for the state.

    row.LabelString = "Idle" + newline + "en: x = 0;";

    Get a handle to an existing state row by using getRow.

    row = stt.getRow("Active");

    Add child state rows and mark one as the default state.

    childRow1 = row.addChildStateRow();
    childRow1.Name = "Running";
    childRow1.IsDefaultState = true;
    childRow2 = row.addChildStateRow();
    childRow2.Name = "Paused";

    Add an inner transition path row to the state. Inner and default transition path rows require the parent state to have child states.

    innerRow = row.addInnerTransitionPathRow();
    innerRow.RowType

    Add a default transition path row to the state.

    defaultRow = row.addDefaultTransitionPathRow();
    defaultRow.RowType

    Get a handle to an existing state row and add a sibling state row below it.

    row = stt.getRow("Idle");
    siblingRow = row.addStateRowBelow();
    siblingRow.Name = "Active";

    Version History

    Introduced in R2026b

    expand all