MATLAB: Does reading and converting UINT64 data fail with FREAD in MATLAB 7.0.1 (R14SP1)

freadinvalidMATLABprecisionr14uint64

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.

Best Answer

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'));