主要内容

数字类型

Integer and floating-point data

Numeric classes in MATLAB®包括签署和无符号整数,和precision and double-precision floating-point numbers. By default, MATLAB stores all numeric values as double-precision floating point. (You cannot change the default type and precision.) You can choose to store any number, or array of numbers, as integers or as single-precision. Integer and single precision arrays offer more memory-efficient storage than double precision.

All numeric types support basic array operations, such as indexing, reshaping, and mathematical operations.

Functions

expand all

double 双精度阵列
single Single-precision arrays
int8 8-bit signed integer arrays
INT16 16位签名的整数阵列
int32 32-bit signed integer arrays
int64 64-bit signed integer arrays
uint8 8-bit unsigned integer arrays
uint16 16-bit unsigned integer arrays
uint32 32-bit unsigned integer arrays
uint64 64-bit unsigned integer arrays
cast Convert variable to different data type
typecast Convert data type without changing underlying data
全菲斯 Determine if all array elements are finite
anynan Determine if any array element isNaN
isinteger 确定输入是否为整数数组
isfloat Determine if input is floating-point array
isnumeric 确定输入是否为数字数组
isreal Determine whether array uses complex storage
isfinite 确定哪些数组元素是有限的
isinf Determine which array elements are infinite
isnan Determine which array elements are NaN
eps 浮点相对精度
flintmax Largest consecutive integer in floating-point format
inf Create array of allinf
intmax Largest value of specific integer type
intmin Smallest value of specific integer type
NaN Create array of allNaN
realmax Largest positive floating-point number
领域 最小的标准化浮点数

Topics

  • Floating-Point Numbers

    MATLAB represents floating-point numbers in either double-precision or single-precision format. The default is double precision.

  • Single Precision Math

    This example shows how to perform arithmetic and linear algebra with single precision data.

  • Integers

    MATLAB supports 1-, 2-, 4-, and 8-byte storage for integer data. If you use the smallest integer type that accommodates your data, you can save memory and program execution time.

  • Integer Arithmetic

    This example shows how to perform arithmetic on integer data representing signals and images.

  • Create Complex Numbers

    Create complex numbers. Complex numbers consist of a real part and an imaginary part.

  • infinity and NaN

    MATLAB代表特殊价值的无穷大inf, and values that are neither real nor complex by the special valueNaN, which stands for “Not a Number”.

  • 识别数字类

    You can check the data type of a variable using any of these commands.

  • Display Format for Numeric Values

    Use the格式function or set Preferences to control the display of numeric values.

  • Combining Unlike Integer Types

    如果将不同的整数类型组合在矩阵中(例如,用无符号或8位整数签名,带有16位整数),则将所得矩阵的所有元素均给出了最左边元素的数据类型。

  • Combining Integer and Noninteger Data

    如果您将整数与double,single, orlogicalclasses, all elements of the resulting matrix are given the data type of the leftmost integer.

  • Empty Matrices

    If you construct a matrix using empty matrix elements, the empty matrices are ignored in the resulting matrix.

  • Concatenation Examples

    这些示例显示了如何连接不同的数据类型。

  • Hexadecimal and Binary Values

    将十六进制和二进制值指定为文字或文本。十六进制和二元文字作为整数存储。您可以将代表十六进制和二进制值的文本转换为数字,而数字为文本表示。