MATLAB 帮助中心
将数值转换为字符数组
s = num2str(A)
s = num2str(A,precision)
s = num2str(A,formatSpec)
s = num2str(A) 将 fi 对象 A 转换为字符数组表示。其输出适合作为 eval 函数的输入,它可使 eval(s) 精确地产生原始的 fi 对象。
s
A
fi
eval
eval(s)
示例
s = num2str(A,precision) 使用 precision 指定的精度位数将 fi 对象 A 转换为字符数组表示。
precision
s = num2str(A,formatSpec) 将 formatSpec 指定的格式应用于 A 的所有元素。
formatSpec
全部折叠
创建一个 fi 对象 A,并将其转换为字符向量。
A = fi(pi)
A = 3.1416 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 13
S = num2str(A)
S = '3.1416'
创建一个 fi 对象,并将其转换为具有 8 位精度的字符向量。
S = num2str(A,8)
S = '3.1416016'
输入数组,指定为数值数组。
数据类型: fi | double | single | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical 复数支持: 是
double
single
int8
int16
int32
int64
uint8
uint16
uint32
uint64
logical
输出字符串中的有效数字最大位数,指定为正整数。
数据类型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64
输出字段的格式,使用格式化操作符指定。formatSpec 还可以包括普通文本和特殊字符。
有关格式化操作符的详细信息,请参阅 MATLAB® 文档中的 num2str 参考页。
num2str
输入数组的文本表示,以字符数组形式返回。
在 R2016a 中推出
num2str | mat2str | tostring
mat2str
tostring
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处