Main Content

uint16

16-bit unsigned integer arrays

Description

Variables in MATLAB®of data type (class)uint16are stored as 2-byte (16-bit) unsigned integers. For example:

y = uint16(10); whosy
Name Size Bytes Class Attributes y 1x1 2 uint16

For more information on integer types, seeIntegers.

Creation

Some array creation functions allow you to specify the data type. For instance,0(100年,“uint16”)creates a 100-by-100 matrix of zeros of typeuint16.

If you have an array of a different type, such asdoubleorsingle, then you can convert that array to an array of typeuint16by using theuint16function.

Syntax

Description

example

Y = uint16(X)converts the values inXto typeuint16. Values outside the range [0,216-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|int16|int32|int64|uint8|uint32|uint64|logical|char

Examples

collapse all

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

x = 100;xtype类(x) =
xtype = 'double'
y = uint16(x)
y =uint16100

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

Introduced before R2006a