Specify Precision

Convert Integers

Create an array of integers and convert it to a character vector. By default, the output of mat2str represents an array of doubles. To represent a different numeric type in the output, use the 'class' input argument.

Create a vector of 16-bit unsigned integers.

X = uint16([256 512])

X = 1x2 uint16 row vector
256 512

Convert X to a character vector, including the data type of X.

chr = mat2str(X,'class')

chr =
'uint16([256 512])'

Convert chr back to an array of integers. A has the same values and data type as X.