16-bit signed integer arrays
Variables in MATLAB® of data type (class)
int16 are stored as
2-byte (16-bit) signed integers. For example:
y = int16(10); whos y
Name Size Bytes Class Attributes y 1x1 2 int16
For more information on integer types, see Integers.
Some array creation functions allow you to specify the data type. For instance,
zeros(100,'int16') creates a 100-by-100 matrix of zeros of type
If you have an array of a different type, such as
single, then you can convert that array to an array of type
int16 by using the
Y = int16(X)
X— Input array
Input array, specified as a scalar, vector, matrix, or multidimensional array.
Convert a double-precision variable to a 16-bit signed integer.
x = 100; xtype = class(x)
xtype = 'double'
y = int16(x)
y = int16 100
This function fully supports tall arrays. For more information, see Tall Arrays.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).