fread returns wrong array size for non-zero skip
이전 댓글 표시
I am having trouble using fread on a binary file. fread appears to be returning the wrong number of elements in some cases when I set a non-zero skip parameter, and array sizes greater than 1024.
That is,
>> [val,vsize] = fread(fid,[1023,1],'1023*bit12=>int16',0,'ieee-le');
and
>> [val,vsize] = fread(fid,[1023,1],'1023*bit12=>int16',8,'ieee-le');
both work as expected.
This works:
>> [val,vsize] = fread(fid,[1025,1],'1025*bit12=>int16',0,'ieee-le');
but not this:
>> [val,vsize] = fread(fid,[1025,1],'1025*bit12=>int16',8,'ieee-le');
In the latter case, vsize is 2048 and val becomes a 1024x2 array padded with 1023 zeros.
It appears that with a non-zero skip parameter, fread always returns vsize rounded upwads to the nearest 1024 (2900 is rounded upwards to 3072, 4000 to 4096 and so on), and an array padded with zeros to that length.
This becomes a major problem, as I want to read a large number of vectors in one go:
>> [val,vsize] = fread(fid,[4000,5000],'4000*bit12=>int16',352,'ieee-le');
Any ideas what is going on?
I am using R2012a (64 bit) on Windows 7.
댓글 수: 1
mchristoffersen
2016년 7월 15일
I am having the same issue, did you ever find a resolution?
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Functions에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!