Main Content

tostring

将值转换为字符串

描述

示例

str = tostring(X) 将数值、布尔或枚举数据 X 转换为字符串。

注意

仅在使用 C 语言作为动作语言的 Stateflow® 图中支持运算符 tostring。在使用 MATLAB® 作为动作语言的图中,请使用 string

示例

全部展开

将数值转换为字符串 "1.2345"

str = tostring(1.2345);

Stateflow chart that uses the tostring operator in a state.

将布尔值转换为字符串 "true"

str = tostring(true);

Stateflow chart that uses the tostring operator in a state.

将枚举值转换为字符串 "RED"

str = tostring(RED);

Stateflow chart that uses the tostring operator in a state.

版本历史记录

在 R2018b 中推出