Numeric Types
MATLAB中的数字类®包括签名和未签名的整数,以及单精制和双精度浮点数。默认情况下,MATLAB将所有数字值存储为双精度浮点。(您不能更改默认类型和精度。)您可以选择将任何数字或数字存储为整数或单精度。整数和单个精度阵列提供的存储效率更高,而不是双重精度。
所有数字类型都支持基本数组操作,例如金宝app索引,重塑和数学操作。
功能
话题
MATLAB以双精度或单精制格式表示浮点数。默认值是双重精度。
此示例显示了如何使用单个精确数据执行算术和线性代数。
MATLAB支金宝app持整数数据的1-,2-,4-和8字节存储。如果使用适合数据的最小整数类型,则可以节省内存和程序执行时间。
此示例显示了如何在表示信号和图像的整数数据上执行算术。
创建复杂数字。复数由实际部分和虚构部分组成。
MATLABrepresents infinity by the special valueinf
,以及特殊价值既不是真实也不复杂的价值南
,代表“不是数字”。
您可以使用这些命令中的任何一个检查变量的数据类型。
使用format
功能或设置首选项以控制数字值的显示。
If you combine different integer types in a matrix (e.g., signed with unsigned, or 8-bit integers with 16-bit integers), all elements of the resulting matrix are given the data type of the leftmost element.
If you combine integers with双倍的
,,,,单身的
, 或者逻辑
类,所得矩阵的所有元素都给出了最左侧整数的数据类型。
如果使用空矩阵元素构造矩阵,则在生成的矩阵中忽略了空矩阵。
These examples show how to concatenate different data types.
Specify hexadecimal and binary values either as literals or as text. Hexadecimal and binary literals are stored as integers. You can convert text representing hexadecimal and binary values to numbers, and numbers to text representations.