Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Numeric Types

Integer and floating-point data

Numeric classes in MATLAB® include signed and unsigned integers, and single-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 subscripting, reshaping, and mathematical operations.

Functions

doubleDouble-precision arrays
singleSingle-precision arrays
int88-bit signed integer arrays
int1616-bit signed integer arrays
int3232-bit signed integer arrays
int6464-bit signed integer arrays
uint88-bit unsigned integer arrays
uint1616-bit unsigned integer arrays
uint3232-bit unsigned integer arrays
uint6464-bit unsigned integer arrays
castCast variable to different data type
typecastConvert data types without changing underlying data
isintegerDetermine if input is integer array
isfloatDetermine if input is floating-point array
isnumericDetermine if input is numeric array
isrealDetermine whether array is real
isfiniteArray elements that are finite
isinfArray elements that are infinite
isnanArray elements that are NaN
epsFloating-point relative accuracy
flintmaxLargest consecutive integer in floating-point format
InfInfinity
intmaxLargest value of specified integer type
intminSmallest value of specified integer type
NaNNot-a-Number
realmaxLargest positive floating-point number
realminSmallest positive normalized floating-point number

Topics

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.

Floating-Point Numbers

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

Complex Numbers

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

Infinity and NaN

MATLAB represents infinity by the special value inf, and values that are neither real nor complex by the special value NaN, which stands for “Not a Number”.

Identifying Numeric Classes

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

Display Format for Numeric Values

The format function controls the display of numeric values. Changing the format does not change the values, only their display.

Combining Unlike Integer Types

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.

Combining Integer and Noninteger Data

If you combine integers with double, single, or logical classes, 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

These examples show how to concatenate different data types.

Was this topic helpful?