%% Convert 8-Bit Integer to 16-Bit Integer
% Casts integers from a smaller data type (uint8) into a larger one (uint16). Use hexadecimal representation to show the rearrangement of the bit patterns. The typecast function returns the output in little-endian style, combining the four 8-bit segments of the input data to produce two 16-bit segments.

format hex
X = uint8([44 55 66 77])
Y = typecast(X,'uint16')

% You can convert the little-endian output to big-endian (and vice versa) using the swapbytes function.

Y = swapbytes(typecast(X,'uint16'))

%
% Copyright 2019 The MathWorks, Inc.