MATLAB convert big-endian order bytes into floating point values
byte, endianness, floating-point, matlab
Solution
great example here:
>> dataL = typecast(uint8([189, 33, 136, 147]), 'uint32')
dataL =
2475172285
>> dataF = double(dataL)
dataF =
2.4752e+09
big to little, try `swapbytes`
>> dataLbig = swapbytes(dataL)
dataLbig =
3173091475
>> dataFbig = double(dataLbig)
dataFbig =
3.1731e+09
Is this what you were expecting?
Problem
I have the following bytes stored in a vector: ``` data = [189 33 136 147] ``` These 4 bytes represent a single float in Big-endian order. How can I get this number in MATLAB? I will need to concatenate and convert. I tried: ``` x = typecast(str2num(sprintf('%d%d%d%d',data(1),data(2),data(3),data(4))), 'single') ``` To no avail (I got `x = []`).