fread + double-precision 8-byte floating point + precision

Hi All,
I want to use fread to read my binary file. The data type are "double-precision 8-byte floating point". When I put 8*double as precision, it gives me weird values that I am sure it is wrong. How can I put both float + double in precision?
Thanks a lot

 채택된 답변

Geoff Hayes
Geoff Hayes 2015년 10월 30일
Farz - if the data type (within your file) is double-precision 8-byte floating point, then why not just use double or float64 as either should correspond to 8-byte floating point numbers? Check out fread input argument precision and use fread as (for example)
A = fread(fileID,[3 3],'double');

댓글 수: 3

Thanks, I realized when I use 'double' precision it gives me strange number. I think the problem is because the data are also Least Significant Byte/little-endian. Now I need to deal with this.
Hi Farz - you should be able to set the machine format when you open the file with fopen. See http://www.mathworks.com/help/matlab/ref/fopen.html#inputarg_machinefmt for details.
It is LSB format data but putting 'l' did not help me in reading the data.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

aijiangzhao aixuwu
aijiangzhao aixuwu 2021년 10월 27일

0 개 추천

Hi,I encountered the same problem, did you solve it? Can you tell me?

카테고리

도움말 센터File Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

제품

질문:

2015년 10월 29일

답변:

2021년 10월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by