Main Content

本页翻译不是最新的。点击此处可查看最新英文版本。

状态和转移的语法

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

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

模块

全部展开

Chart用有限状态机实现控制逻辑
State Transition Table以表格形式表示模态逻辑
Truth Table用条件、决策和动作来表示逻辑决策行为

Stateflow 语法

全部展开

更改检测

hasChanged检测自上一时间步以来的数据更改
hasChangedFrom检测从指定值以来的数据变化
hasChangedTo检测到指定值时的数据变化
change当数据更改值时生成隐式事件

边沿检测

crossing检测自上一时间步以来数据中的上升沿或下降沿
falling检测自上一时间步以来数据中的下降沿
rising检测自上一时间步以来数据中的上升沿

消息活动

send广播消息或事件
receive从队列中提取消息
discard丢弃消息
forward转发消息
isvalidDetermine if message is valid
lengthDetermine length of message queue

状态活动

in检查状态活动
enter当状态变为激活时生成隐式事件
exit当状态变为非激活时生成隐式事件

数据类型转换

boolean将数值转换为布尔值
ascii2str将类型为 uint8 的数组转换为字符串
str2ascii将字符串转换为 uint8 类型的数组
str2double将字符串转换为双精度值
string将值转换为字符串
tostring将值转换为字符串
typeType of Stateflow data object

字符串创建和串联

blanks由空白字符组成的字符数组
plus串联字符串
strcpy字符串赋值
strcat串联字符串

字符串数据的属性

isletterDetermine which characters are letters in Stateflow chart
isspaceDetermine which characters are spaces in Stateflow chart
isstring确定输入是否为字符串
strlen确定字符串的长度
strlength确定字符串的长度

查找和替换子字符串

contains确定字符串是否包含子字符串
startsWith确定字符串是否以子字符串开头
endsWith确定字符串是否以子字符串结尾
strfind在字符串中查找子字符串
extractAfter提取指定位置后的子字符串
extractBefore提取指定位置前的子字符串
substr从字符串中提取子字符串
replace查找和替换子字符串
replaceBetweenReplace substrings between start and end points in Stateflow chart
strrep查找和替换子字符串
erase删除字符串内的子字符串
eraseBetweenDelete substring between start and end points in Stateflow chart
insertAfter在子字符串后插入字符串
insertBeforeInsert string before substring in Stateflow chart

编辑字符串数据

lower将字符串转换为小写
upper将字符串转换为大写
reverseReverse order of characters in strings in Stateflow chart
stripRemove leading and trailing characters from string in Stateflow chart
strtrim从字符串中删除前导和尾随空白

比较字符串数据

matches确定两个字符串是否匹配
strcmp比较字符串(区分大小写)
strcmpi比较字符串(不区分大小写)
strncmp比较字符串的前 N 个字符(区分大小写)
strncmpiCompare first N characters of strings in Stateflow chart (case insensitive)

时序逻辑

after在事件广播或指定时间后执行图
at在事件广播时或指定时间执行图
before在事件广播或指定时间之前执行图
every按固定间隔执行图
duration条件有效期间的时间长度
elapsed自状态激活以来的时间
count条件有效期间的图执行次数
temporalCount事件数、图执行次数或自状态激活以来的时间

MATLAB 代码对接

thisAccess chart data during simulation

主题