How can I read a binary file with multiple word formats?
Mostra commenti meno recenti
So I'm working on a file that is a stream of 16-bit words that I need to extract data from. The first word is actually 32-bits (word 1 and word 2 concatenated together) followed by 3 more 16-bit words. This pattern repeats to the end of the file.
I currently have:
fidin = fopen('Filename.RAW','r');
time = fread(fidin,[1,inf],'bit32',6);
fseek(fidin,4,'bof');
words = fread(fidin,[3,inf],'bit16',4);
but it doesn't seem to be outputting the information in the style I'm looking for. I know what the data should look like because I have a separately created text file of the same data and it look nothing like it.
I figured I could read all the 16+16bit time words as one run of the file, then skip to 4 bytes into the file and read all of the 3x16-bit words as a second run. This does not seem to be the case.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Low-Level File I/O in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!