MATLAB读取混合数据类型的二进制文件 [英] MATLAB reading a mixed data type binary file

查看:363
本文介绍了MATLAB读取混合数据类型的二进制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法读取非常大的二进制文件(1,000,000字节以上)

I am having trouble reading a very large binary file (1,000,000 bytes +)

如果我以1字节数据格式(例如'uint8')以fread格式读取文件,则读取的数据量等于文件的大小,因此内存不是问题.

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.

我知道在此二进制文件中有类型为'int16''single'的数据,但是我不知道文件的结构.我认为文件是结构化的,所以有一个'int16'数据点,后跟一个'single'数据点,并且一直重复到文件末尾.

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

推荐答案

使用skip属性可以一步一步读取singleuint16

using the skip property allows to read the single and uint16 in one step each

A = fread(fileID,sizeA,precision,skip)

未经测试的示例代码:

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

这篇关于MATLAB读取混合数据类型的二进制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆