问题
I am having trouble reading a very large binary file (1,000,000 bytes +)
If I fread
the file in a 1 byte data format for example 'uint8'
the number of data read equals the size of the file so memory isn't an issue.
I know in this binary file there is data of type 'int16'
and 'single'
however I don't know the structure of the file. I think the file is structured so there is an 'int16'
data point followed by a 'single'
data point and this is repeated until the end of the file.
I do not know how to do this reading of mixed data types.
I think I need a loop of some sort?
Thanks in advance for any help or suggestions given
回答1:
using the skip property allows to read the single
and uint16
in one step each
A = fread(fileID,sizeA,precision,skip)
Not tested Sample Code:
Integer16 = fread(fileID,sizeA,'uint16',8); %read uin16 and skip the siz eof a single
fseek(fileID, 2, 0) % offset the size of a uint16
Single = fread(fileID,sizeA,'single',2); % read the singles
来源:https://stackoverflow.com/questions/32457759/matlab-reading-a-mixed-data-type-binary-file