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

4 views (last 30 days)
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.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
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'));

More Answers (0)

Categories

Find more on Behavior and Psychophysics in Help Center and File Exchange

Products


Release

R14SP1

Community Treasure Hunt

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

Start Hunting!