How to read and store binary data from a file and store it into the MATLAB in row major using fread function?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
MathWorks Support Team
il 20 Giu 2017
Risposto: MathWorks Support Team
il 30 Giu 2017
I'd like to read in the binary file and generate 2 columns of data as shown in the text file.
The binary data consists of 16 bit signed integers from two channels of A/D data. The samples in the binary file alternate by channels, and it would be nice to turn the data into an array of two columns for the two channels.
For example consider a file contains following data:
1 2 3 4 5 6 7 8
I would like to read data as:
1 2
3 4
5 6
7 8
Risposta accettata
MathWorks Support Team
il 20 Giu 2017
MATLAB always stores data into column major. But as workaround to this issue you can read the file as 2 rows and multiple columns and transpose the matrix to get expected result.
For example the file can be read as:
fileID = fopen('test1.bin');
A = fread(fileID,[2 inf],'int16');
B = transpose(A);
fclose(fileID);
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Text Files in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!