Main Content

exportAsStruct

Export contents of state transition table as structure array

Since R2022b

Description

structure = exportAsStruct(table) returns a structure array that contains the contents of the state transition table table.

example

structure = exportAsStruct(table,hierarchical) specifies whether the function returns an array of structures or a hierarchy of structures based on the value of hierarchical.

example

Examples

collapse all

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]

Export the contents of the state transition table in Model Bang-Bang Controller by Using a State Transition Table as a hierarchy 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 a hierarchy of structures.

structure = exportAsStruct(table,true)
structure = 

  struct with fields:

       tableData: [1×2 struct]
    columnWidths: [209 175 174]
         tableId: 172

View the contents of a top-level state.

structure.tableData(1)
ans = 

  struct with fields:

                  stateLabel: 'Normal'
                 transitions: [1×2 struct]
                  rowHeights: {[30]  [30]  [30]}
                  hasHistory: 0
    isDefaultTransitionOwner: 1
                 isWhenState: 0
                  isExpanded: 1
             hasRequirements: 0
              hasBreakpoints: 0
       hasEnabledBreakpoints: 0
                    children: [1×3 struct]
                     rowType: 0
        possibleDestinations: {''  'Alarm'  '$NEXT'  '$SELF'  '% IGNORE %'}
           decompositionInfo: [1×1 struct]

View the contents of a child state.

structure.tableData(1).children(3)
ans = 

  struct with fields:

                  stateLabel: 'On↵entry:↵boiler_cmd = 1;'
                 transitions: [1×2 struct]
                  rowHeights: {[53]  [30]  [30]}
                  hasHistory: 0
    isDefaultTransitionOwner: 0
                 isWhenState: 0
                  isExpanded: 0
             hasRequirements: 0
              hasBreakpoints: 0
       hasEnabledBreakpoints: 0
                    children: []
                     rowType: 0
        possibleDestinations: {''  '$PREV'  'Off'  'Warmup'  '$SELF'  '% IGNORE %'}
           decompositionInfo: [1×1 struct]

Input Arguments

collapse all

State transition table, specified as a Stateflow.StateTransitionTableChart object.

Whether to create a hierarchy of structures, specified as a numeric or logical 1 (true) or 0 (false). This argument determines the format of the output argument structure.

Output Arguments

collapse all

Contents of state transition table, returned as a structure array. The format of structure depends on the input argument hierarchical:

  • If hierarchical is false, structure is an array that contains a structure for each state in the state transition table. In each of these structures, the field depth indicates the level of each state in the hierarchy. See Create Array of Structures.

  • If hierarchical is true, structure is a structure with the fields tableData, columnWidths, and tableId. tableData is an array that contains a structure for each top-level state in the state transition table. In each of these structures, the field children is an array that contains a structure for each substate. This pattern continues down the hierarchy of states in the state transition table. See Create Hierarchy of Structures.

Version History

Introduced in R2022b