%% Swap Byte Ordering of 3-D Array
% Create a three-dimensional array A of 16-bit integers. Swap the byte ordering of each element. Use hexadecimal representation to show the endian conversion.

format hex
X = uint16(magic(3)*150);
X(:,:,2) = X*40;
X
Y = swapbytes(X)

%
% Copyright 2019 The MathWorks, Inc.