Skip to content

swapbytes

miscellaneous · scripts/miscellaneous/swapbytes.m

: y = swapbytes (x)

Reverse the order of the bytes in every element of the numeric array x.

The result has the class and the size of x. One-byte integer classes are returned unchanged. For floating-point input the bit pattern is reversed and read back as the same floating-point class; for complex input the real and imaginary parts are treated separately.