Main Content

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

字符串数据

基于文本的值

字符串是一段文本数据。使用 Stateflow® 图中的字符串来控制图行为或创建自然语言输出。将字符串数据纳入记录、消息和自定义代码工作流中。

Stateflow 语法

全部展开

创建、串联和转换

string将值转换为字符串
blanks由空白字符组成的字符数组
plus串联字符串
str2double将 Stateflow 图中的字符串转换为双精度值

确定类型和属性

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

查找和替换

contains确定 Stateflow 图中的字符串是否包含子字符串
startsWith确定 Stateflow 图中字符串是否以子字符串开头
endsWith确定 Stateflow 图中的字符串是否以子字符串结尾
strfind在 Stateflow 图中的字符串内查找子字符串
extractAfter提取指定位置后的子字符串
extractBefore提取指定位置前的子字符串
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将 Stateflow 图中的字符串转换为大写
reverseReverse order of characters in strings in Stateflow chart
stripRemove leading and trailing characters from string in Stateflow chart
strtrim从 Stateflow 图中的字符串删除前导和尾随空白

比较

matches确定 Stateflow 图中两个字符串是否匹配
strcmp比较字符串(区分大小写)
strcmpi比较字符串(不区分大小写)
strncmp比较 Stateflow 图中字符串的前 N 个字符(区分大小写)
strncmpiCompare first N characters of strings in Stateflow chart (case insensitive)
ascii2str将类型为 uint8 的数组转换为字符串
str2ascii将字符串转换为 uint8 类型的数组
str2double将 Stateflow 图中的字符串转换为双精度值
strcat串联字符串
strcmp比较字符串(区分大小写)
strcpy字符串赋值
strlen确定字符串的长度
substr从字符串中提取子字符串
tostring将值转换为字符串

主题