fread returns wrong array size for non-zero skip

6 visualizaciones (últimos 30 días)
DNF
DNF el 21 de Jun. de 2012
Comentada: mchristoffersen el 15 de Jul. de 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 comentario
mchristoffersen
mchristoffersen el 15 de Jul. de 2016
I am having the same issue, did you ever find a resolution?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by