num2str
将数值转换为字符数组
说明
示例
将 fi 对象转换为字符向量
创建一个 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 对象转换为具有指定精度的字符
创建一个 fi
对象,并将其转换为具有 8 位精度的字符向量。
A = fi(pi)
A = 3.1416 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 13
S = num2str(A,8)
S = '3.1416016'
输入参数
A
— 输入数组
数值数组
输入数组,指定为数值数组。
数据类型: fi
| double
| single
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| logical
复数支持: 是
precision
— 精度位数
正整数
输出字符串中的有效数字最大位数,指定为正整数。
数据类型: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
formatSpec
— 输出字段的格式
格式化操作符
输出字段的格式,使用格式化操作符指定。formatSpec
还可以包括普通文本和特殊字符。
有关格式化操作符的详细信息,请参阅 MATLAB® 文档中的 num2str
参考页。
输出参数
s
— 输入数组的文本表示
字符数组
输入数组的文本表示,以字符数组形式返回。
版本历史记录
在 R2016a 中推出
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)