Main Content

str2ascii

将字符串转换为 uint8 类型的数组

描述

示例

A = str2ascii(str,n) 返回类型为 uint8 的数组,该数组包含 str 中前 n 个字符的 ASCII 值,其中 n 是正整数。如果 str 的字符数少于 n,则 A 的其余元素将设置为 0

不支持对 n 使用变量或表达式。

注意

仅在使用 C 语言作为动作语言的 Stateflow® 图中支持运算符 str2ascii

示例

全部展开

返回 uint8 数组 {72,101,108,108,111}

str = "Hello, world!";
A = str2ascii(str,5);

Stateflow chart that uses the str2ascii operator in a state.

提示

  • 用单引号或双引号将文字字符串引起来。

版本历史记录

在 R2018b 中推出