Documentation

This is machine translation

Mouseover text to see original. Click the button below to return to the English version of the page.

int16

16-bit signed integer arrays

Description

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 ```

Creation

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 `int16`.

If you have an array of a different type, such as `double` or `single`, then you can convert that array to an array of type `int16` by using the `int16` function.

Syntax

``Y = int16(X)``

Description

example

````Y = int16(X)` converts the values in `X` to type `int16`. Values outside the range [-215,215-1] map to the nearest endpoint.```

Input Arguments

expand all

Input array, specified as a scalar, vector, matrix, or multidimensional array.

Data Types: `double` | `single` | `int8` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64` | `logical` | `char`

Examples

collapse all

Convert a double-precision variable to a 16-bit signed integer.

```x = 100; xtype = class(x)```
```xtype = 'double' ```
`y = int16(x)`
```y = int16 100 ```