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 Model Finite State Machines Using State Transition Tables.
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
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
— Name of state transition table
"State Transition Table"
(default) | string scalar | character vector
Name of the state transition table, specified as a string scalar or character vector.
ActionLanguage
— Action language
"MATLAB"
(default) | "C"
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.
StateMachineType
— State machine semantics
"Classic"
(default) | "Mealy"
| "Moore"
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.
SupportVariableSizing
— Whether state transition table supports variable-size data
true
or 1 (default) | false
or 0
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.
TreatDimensionOfLengthOneAsFixedSize
— Whether state transition table treats output data with dimension of length 1 as fixed size
true
or 1
(default) | false
or 0
Since R2023a
Whether the state transition table treats output data with a dimension of length 1
as fixed size, specified as a numeric or logical 0
(false
) or 1
(true
). When
this property is true
, the state transition table treats output
data that have at least one dimension of length 1 as fixed size, regardless of whether
you specify the data as having variable size. When this property is
false
, the state transition table treats output data as variable
size if you specify the data as having variable size.
Chart Initialization
ExecuteAtInitialization
— Whether to initialize state configuration
false
or 0 (default) | true
or 1
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.
StatesWhenEnabling
— Behavior of states when event reenables state transition table
""
(default) | "held"
| "reset"
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.
InitializeOutput
— Whether to initialize output data
false
or 0 (default) | true
or 1
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
HasOutputData
— Whether to create active state data output
false
or 0 (default) | true
or 1
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.
OutputData
— Active state data object
Stateflow.Data
object
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
.
OutputPortName
— Name of active state data object
string scalar | character vector
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
.
OutputMonitoringMode
— Monitoring mode for active state output
"ChildActivity"
(default) | "LeafStateActivity"
Monitoring mode for the active state output data, specified as
"ChildActivity"
or "LeafStateActivity"
.
EnumTypeName
— Name of enumerated data type for active state data object
string scalar | character vector
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.
DoNotAutogenerateEnum
— Whether to define enumerated data type manually
false
or 0 (default) | true
or 1
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
ChartUpdate
— Activation method for state transition table
"INHERITED"
(default) | "CONTINUOUS"
| "DISCRETE"
Activation method for the state transition table, specified as
"CONTINUOUS"
, "DISCRETE"
, or
"INHERITED"
.
SampleTime
— Sample time for activating state transition table
"-1"
(default) | string scalar | character vector
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"
.
EnableZeroCrossings
— Whether to enable zero-crossing detection
true
or 1 (default) | false
or 0
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
EnableNonTerminalStates
— Whether to enable super step semantics
false
or 0 (default) | true
or 1
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.
NonTerminalMaxCounts
— Maximum number of transitions in one super step
1000
(default) | scalar
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
.
NonTerminalUnstableBehavior
— Behavior if super step exceeds maximum number of transitions
"Proceed"
(default) | "Throw Error"
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
SaturateOnIntegerOverflow
— Whether data saturates on integer overflow
true
or 1 (default) | false
or 0
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.
TreatAsFi
— Inherited Simulink signals to treat as fi
objects
"Fixed-point"
(default) | "Fixed-point & Integer"
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 asfi
objects."Fixed-point & Integer"
— The state transition table treats all fixed-point and integer inputs asfi
objects.
This property applies only when the ActionLanguage
property
of the state transition table is "MATLAB"
.
EmlDefaultFimath
— Default fimath
properties
"Same as MATLAB Default"
(default) | "Other:UserSpecified"
Default fimath
properties for the state transition table,
specified as one of these values:
"Same as MATLAB Default"
— Use the samefimath
properties as the current defaultfimath
object."Other:UserSpecified"
— Use theInputFimath
property to specify the defaultfimath
object.
This property applies only when the ActionLanguage
property
of the state transition table is "MATLAB"
.
InputFimath
— Default fimath
object
string scalar | character vector
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
EnableBitOps
— Whether to use bit operations
false
or 0 (default) | true
or 1
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.
Debugging
Debug
— Debugger properties
Stateflow.ChartDebug
object
Debugger properties for the state transition table, specified as a Stateflow.ChartDebug
object with this property:
Breakpoints.OnEntry
— Whether to set theOn 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
Editor
— Editor
Stateflow.Editor
object
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.
Visible
— Whether editor is displaying state transition table
true
or 1 | false
or 0
Whether the Stateflow Editor window is displaying the state transition table, specified as a
numeric or logical 1 (true
) or 0 (false
).
ChartColor
— Background color
[1 0.9608 0.8824]
(default) | [red green blue]
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.
StateColor
— Color for states
[0 0 0]
(default) | [red green blue]
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.
TransitionColor
— Color for transitions
[0.2902 0.3294 0.6039]
(default) | [red green blue]
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.
JunctionColor
— Color for junctions
[0.6824 0.3294 0]
(default) | [red green blue]
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.
StateFont
— Font for state labels
Stateflow.STTStateFont
object
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;
StateLabelColor
— Color for state labels
[0 0 0]
(default) | [red green blue]
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.
TransitionFont
— Font for transition labels
Stateflow.STTTransFont
object
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;
TransitionLabelColor
— Color for transition labels
[0.2902 0.3294 0.6039]
(default) | [red green blue]
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
Machine
— Machine that contains state transition table
Stateflow.Machine
object
This property is read-only.
Machine that contains the state transition table, specified as a Stateflow.Machine
object.
Path
— Location of state transition table in model hierarchy
character vector
This property is read-only.
Location of the state transition table in the model hierarchy, specified as a character vector.
Dirty
— Whether state transition table has changed
true
or 1 | false
or 0
Whether the state transition table has changed after being opened or saved,
specified as a numeric or logical 1 (true
) or 0
(false
).
Locked
— Whether state transition table is locked
false
or 0 (default) | true
or 1
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.
Iced
— Whether state transition table is locked
false
or 0 (default) | true
or 1
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
— Description
""
(default) | string scalar | character vector
Description for the state transition table, specified as a string scalar or character vector.
Document
— Document link
""
(default) | string scalar | character vector
Document link for the state transition table, specified as a string scalar or character vector.
Tag
— User-defined tag
[]
(default) | any data type
User-defined tag for the state transition table, specified as data of any type.
Id
— Unique identifier
scalar
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
find | Identify specified objects in hierarchy |
getChildren | Identify children of object |
dialog | Open properties dialog box |
view | Display object in editing environment |
exportAsStruct | Export contents of state transition table as structure array |
Examples
Create Empty State Transition Table
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");
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]
Version History
Introduced in R2012bR2023b: Convert to chart
To convert a state transition table to a Stateflow chart, use the object function convertToChart
.
R2023a: Specify how to treat output data with dimension of length 1
With the new property TreatDimensionOfLengthOneAsFixedSize
, you can
specify how state transition tables treat output data when at least one dimension has length
1. Prior to R2023a, state transition tables treat output data with a dimension of length 1
as fixed size, regardless of whether you specify the data as having variable size.
R2022b: Export contents of state transition tables
Export the contents of a state transition table as a structure array by calling the
object function exportAsStruct
.
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi 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)