Read a binary file with many type of data (Int64-int32-int64-int32....)
15 ビュー (過去 30 日間)
古いコメントを表示
Hi,
i have a binary file generated by a DAQ equipment
This file contains header + data
this is the structure of the Header
64 bit 32 bit 64 bit 32 bit 32 bit 32 bit
The data is structured : Ch1 Ch2 Ch3 Ch4 Ch5 Ch6 Ch7 Ch8 Ch1 Ch2 Ch3 Ch4 Ch5 Ch6 Ch7 Ch8 Ch1 Ch2 Ch3 Ch4 Ch5 Ch6 Ch7 Ch8 ......
The type of data is int32
sampling rate depends of the configuration in my case is : 4Khz.
any idea ?
i have to read it bit by bit ?
0 件のコメント
回答 (1 件)
Walter Roberson
2023 年 9 月 11 日
fid = fopen('filename');
H1 = fread(fid, 1, '*uint64');
H2 = fread(fid, 1, '*uint32');
H3 = fread(fid, 1, '*uint64');
H4 = fread(fid, 3, '*uint32');
data = fread(fid, [8 inf], 'int32') .';
fclose(fid);
You might need to adjust the datatypes of the header items.
You might need to use swapbytes
3 件のコメント
Walter Roberson
2023 年 9 月 11 日
fid = fopen('filename', 'r', 'ieee-be'); %big endian
header.firstDate_s = fread(fid, 1, '*uint64');
header.firstDate_ns = fread(fid, 1, '*int32');
header.secondDate_s = fread(fid, 1, '*uint64');
header.secondDate_ns = fread(fid, 1, '*int32');
header.maskVoi = fread(fid, 1, '*int32');
header.size = fread(fid, 1, '*int32');
data = fread(fid, [8 inf], 'int32') .';
fclose(fid);
参考
カテゴリ
Help Center および File Exchange で Standard File Formats についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!