Convert to 16-bit signed integer
intArray = int16(array)
Array of any numeric class, such as single or double. If array is already of class int16, the int16 function has no effect.
Array of class int16. Values range from –215 to 215 – 1.
The int16 function maps any values in array that are outside the limit to the nearest endpoint. For example,
int16(2^15) % 2^15 = 32768
ans = 32767
When preallocating integer arrays, specify the class in the call to functions that support a class name input (such as zeros, ones or eye), rather than calling an integer conversion function. For example,
I = int16(zeros(100)); % Creates an intermediate array
is not as efficient as
I = zeros(100, 'int16'); % Preferred