%% 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])

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

chr = mat2str(X,'class')

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

A = eval(chr)

% Copyright 2012 The MathWorks, Inc.