fread returns wrong array size for non-zero skip

4 Ansichten (letzte 30 Tage)
DNF
DNF am 21 Jun. 2012
Kommentiert: mchristoffersen am 15 Jul. 2016
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 Kommentar
mchristoffersen
mchristoffersen am 15 Jul. 2016
I am having the same issue, did you ever find a resolution?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by