Why does reading and converting UINT64 data fail with FREAD in MATLAB 7.0.1 (R14SP1)?

조회 수: 4 (최근 30일)
I can read UINT64 data into MATLAB as DOUBLE, but I want to convert it to be UINT64 in the FREAD command by using *. For example, I try the following code:
a=[1 2 3 4];
fid = fopen('test.bin','w');
fwrite(fid,a,'uint64');
fclose(fid);
fid = fopen('test.bin','r');
b = fread(fid,'*uint64');
fclose(fid);
When I run the code, MATLAB returns the following error:
??? Error using ==> fread
Invalid precision.
If I replace UINT64 with UINT32, the code runs without error.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2009년 6월 27일
This bug has been fixed for MATLAB 7.0.4 (R14SP2). For previous releases, please the following:
We have verified that there is a bug in MATLAB 7.0.1 (R14SP1) that affects the way FREAD handles UINT64 data.
To work around this issue, try returning the data as DOUBLE, but cast it to be UINT64. For example, instead of using:
b = fread(fid,'*uint64');
use:
b = uint64(fread(fid,'uint64'));

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

제품


릴리스

R14SP1

Community Treasure Hunt

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

Start Hunting!

Translated by