Read a binary file with many type of data (Int64-int32-int64-int32....)
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Walter Roberson
le 11 Sep 2023
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 commentaires
Walter Roberson
le 11 Sep 2023
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);
Voir également
Catégories
En savoir plus sur Standard File Formats dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!