I have a binary data file that consists of some M data sets. Each set of data is made up of Nbytes of a specific template, e.g. [uint16, uint16, uint16, uint32, double, uint32, int16]. Right now I'm just looping over how many data sets I have and reading the information in each data set according to it's type.
for j = 1:Mdatasets
this(j) = fread(fid,1,'uint32');
foo(j) = fread(fid,1,'uint16');
foofoo(j) = fread(fid,1,'double');
end
Is there a faster way to do this? It can't take a very long time to read some of my larger files (~500MB). I was thinking that if you could give fread() a data type template to repeat over and over like it can do with a single data type, that would be ideal. Not sure if there is a way to do this, or if someone has a way around it, but for loops take so long.
Best Regards,
Adam
1 Comment
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/154920-reading-binary-files-consisting-of-different-data-types-without-a-for-loop#comment_237218
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/154920-reading-binary-files-consisting-of-different-data-types-without-a-for-loop#comment_237218
Sign in to comment.