MATLAB中的数字类®包括签名和无符号整数,单精度和双精度浮点数。默认情况下,Matlab将所有数值存储为双精度浮点。(您无法更改默认类型和精度。)您可以选择将任何数字或数字数组存储为整数或单数或单精度。整数和单精度阵列提供比双精度更多的内存高效存储。
所有数字类型都支持基本阵列操作,例如金宝app索引,重塑和数学操作。
MATLAB表示双精度或单精度格式的浮点数。默认为双精度。
此示例显示如何使用单精度数据执行算术和线性代数。
MATLAB支金宝app持整数数据的1 - ,2 - ,4-和8字节存储。如果使用满足数据的最小整数类型,则可以节省内存和程序执行时间。
此示例显示如何在整数数据上执行表示信号和图像的算术。
创建复杂数字。复数组成的实体部分和虚部。
马铃薯草represents 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.