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 日

1 投票

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 件のコメント

Farz Tak
Farz Tak 2015 年 10 月 30 日
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.
Geoff Hayes
Geoff Hayes 2015 年 10 月 30 日
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.
Farz Tak
Farz Tak 2015 年 10 月 30 日
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?

カテゴリ

製品

質問済み:

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