字符串数据
字符串是一段文本数据。使用 Stateflow® 图中的字符串来控制图行为或创建自然语言输出。将字符串数据纳入记录、消息和自定义代码工作流中。
Stateflow 语法
MATLAB 动作语言运算符
创建、串联和转换
string | 在 Stateflow 图中将值转换为字符串 |
blanks | 由空白字符组成的字符数组 |
plus | 在 Stateflow 图中串联字符串 |
str2double | 将 Stateflow 图中的字符串转换为双精度值 |
确定类型和属性
isletter | 确定 Stateflow 图中哪些字符是字母 |
isspace | 确定 Stateflow 图中哪些字符是空格 |
isstring | 确定 Stateflow 图中输入是否为字符串 |
strlength | 确定 Stateflow 图中字符串的长度 |
查找和替换
contains | 确定 Stateflow 图中的字符串是否包含子字符串 |
startsWith | 确定 Stateflow 图中字符串是否以子字符串开头 |
endsWith | 确定 Stateflow 图中的字符串是否以子字符串结尾 |
strfind | 在 Stateflow 图中的字符串内查找子字符串 |
extractAfter | 提取 Stateflow 图中指定位置后的子字符串 |
extractBefore | 提取 Stateflow 图中指定位置之前的子字符串 |
replace | 在 Stateflow 图中查找和替换子字符串 |
replaceBetween | Replace substrings between start and end points in Stateflow chart |
strrep | 在 Stateflow 图中查找和替换子字符串 |
erase | 删除 Stateflow 图中字符串内的子字符串 |
eraseBetween | Delete substring between start and end points in Stateflow chart |
insertAfter | 在 Stateflow 图中的子字符串后插入字符串 |
insertBefore | 在 Stateflow 图中的子字符串前插入字符串 |
编辑
lower | 在 Stateflow 图中将字符串转换为小写 |
upper | 将 Stateflow 图中的字符串转换为大写 |
reverse | 反转 Stateflow 图中字符串字符的顺序 |
strip | 从 Stateflow 图中的字符串删除前导和尾随字符 |
strtrim | 从 Stateflow 图中的字符串删除前导和尾随空白 |
比较
主题
- Manage Textual Information by Using Strings
Use text strings in Stateflow charts.
- Log String Data to the Simulation Data Inspector
View text strings in the Simulation Data Inspector and in the MATLAB® workspace.
- Send Messages with String Data
Communicate between charts by using messages with string payloads.
精选示例
Simulate a Media Player
Use enumerated data and strings to define the behavior of a media player.
Share String Data with Custom C Code
Pass string data between Stateflow charts and custom C code.
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 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)