exportAsStruct
Description
specifies whether the function returns an array of structures or a hierarchy of structures
based on the value of structure
= exportAsStruct(table
,hierarchical
)hierarchical
.
Examples
Create Array of Structures
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]
Create Hierarchy of Structures
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
table
— State transition table
Stateflow.StateTransitionTableChart
object
State transition table, specified as a Stateflow.StateTransitionTableChart
object.
hierarchical
— Whether to create hierarchy of structures
false
or 0 (default) | true
or 1
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
structure
— Contents of state transition table
structure array
Contents of state transition table, returned as a structure array. The format of
structure
depends on the input argument
hierarchical
:
If
hierarchical
isfalse
,structure
is an array that contains a structure for each state in the state transition table. In each of these structures, the fielddepth
indicates the level of each state in the hierarchy. See Create Array of Structures.If
hierarchical
istrue
,structure
is a structure with the fieldstableData
,columnWidths
, andtableId
.tableData
is an array that contains a structure for each top-level state in the state transition table. In each of these structures, the fieldchildren
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
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)