direct convert to float64 from the data of output of fread

조회 수: 2 (최근 30일)
Junghak
Junghak 2019년 12월 16일
댓글: Junghak 2019년 12월 16일
Dear Experts,
I got the data which are output of fread function as a UDP communication.
data=[65;233;180;90;80;0;0;0].
I want to convert to this data to float64 double(IEEE 754 floating point format).
I tried as below
%================================%
data=data.';
tp=dec2bin(data).';
tp=reshape(tp,[4,16]).';
tp=bin2dec(tp);
hex = '0123456789abcdef';
hc=hex(tp+1);
f=hex2num(hc);
%================================%
I got f=3.4500e+09
but, Is there any other method better simple direct mehtod to get value f?

채택된 답변

Walter Roberson
Walter Roberson 2019년 12월 16일
swapbytes(typecast(uint8(data),'double'))

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

제품


릴리스

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by