Main Content

本页的翻译已过时。点击此处可查看最新英文版本。

状态和转移的语法

通过使用动作和条件来表达图行为

通过指定状态转移时间以及动作执行时间来控制 Stateflow® 图的执行。通过广播事件同步状态执行。检测数据值的变化,并检查在图执行期间有哪些状态为活动状态。

模块

全部展开

ChartImplement control logic with finite state machine
State Transition TableRepresent modal logic in tabular format
Truth TableRepresent logical decision-making behavior with conditions, decisions, and actions

Stateflow 语法

全部展开

更改检测

changeGenerate implicit event when data changes value
hasChangedDetect change in data since last time step
hasChangedFromDetect change in data from specified value
hasChangedToDetect change in data to specified value

消息活动

discardDiscard message
forwardForward message
isvalidDetermine if message is valid
lengthDetermine length of message queue
receiveExtract message from queue
sendBroadcast message or event

状态活动

enterGenerate implicit event when state becomes active
exitGenerate implicit event when state becomes inactive
inCheck state activity in Stateflow

字符串操作

ascii2strConvert array of type uint8 to string
str2asciiConvert string to array of type uint8
str2doubleConvert string to double-precision value
strcat串联字符串
strcmpCompare strings
strcpyAssign string value
strlenDetermine length of string
substr从字符串中提取子字符串
tostringConvert numeric value to string

时序逻辑

after在事件广播或指定时间后执行图
atExecute chart at event broadcast or specified time
beforeExecute chart before event broadcast or specified time
countChart executions during which condition is valid
durationTime during which condition is valid
elapsedTime since state became active
everyExecute chart at regular intervals
temporalCountNumber of events, chart executions, or time since state became active

主题

命名 Stateflow 对象的规范

保留关键字、名称长度限制和命名限制。

Eliminate Redundant Code by Combining State Actions

Combine entry, during, and exit actions in a state.

Control Function-Call Subsystems by Using bind Actions

Bind a function-call output event to the activity of a state.

组合使用转移和结点以创建分支路径

在转移路径中创建决策点。

支持的 Stateflow 图数据运算

在 Stateflow 图中执行数学计算。

Supported Symbols in Actions

Special symbols available for state and transition actions.

Call Extrinsic MATLAB Functions in Stateflow Charts

Access MATLAB® functions that are not supported for code generation.

Access MATLAB Functions and Workspace Data in C Charts

Call built-in MATLAB functions by using the ml operator.

在 C 语言状态图中调用 C 库函数

在状态和转移标签中访问 C 函数。

Check State Activity by Using the in Operator

Determine if a state is active during chart execution.

检测数据值更改

定义数据在时间步之间更改值时的图行为。

使用时序逻辑控制图的执行

使用基于事件的和绝对时间的时序逻辑运算符。

Control Chart Behavior by Using Implicit Events

Trigger chart actions by changes in data values and state activity.

Control Oscillations by Using the duration Operator

Simplify debouncing logic in charts that have transient signals.

特色示例