reading file in matlab
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
how to read an data file and what it actually do?
function [ iq_signal ] = read_file_iq( filename )
%read_file_tdoa reads a file with IQ data (e.g. from rtl_sdr)
disp('read_file_iq');
% daten vom 1. RX
disp(['IQ read from data file = ' filename]);
fileID = fopen(filename);
a = fread(fileID);
fclose(fileID);
inphase1 = a(1:2:end) -128;
quadrature1 = a(2:2:end) -128;
disp(['successfully read ' int2str(length(inphase1)) ' samples']);
% complex representation
iq_signal = inphase1 + 1i.*quadrature1;
end
3 commentaires
Rik
le 21 Sep 2020
Modifié(e) : Rik
le 21 Sep 2020
Have a read here and here. It will greatly improve your chances of getting an answer. I'll edit your question for you this time. You can put questions in the question body. You can use the editing tools to format your code as code, and make clear what your question is.
Your current question is not clear. What kind of data file are you trying to read? How did you get this code? Can you attach an example file? What kind of output do you expect? Remember that we can't read your mind, so you will have to explain your question to us.
Réponses (1)
Walter Roberson
le 21 Sep 2020
The code is intended to read binary files containing quadrature data.
The code reads the entire file as a series of uint8 values, and automatically converts them to double() [that is the default for fread()] .
The odd-numbered bytes have 128 subtracted from them, and are assigned to inphase1 . So bytes that were stored as 0 become -128, bytes that were stored as 128 become 0, bytes that were stored as 255 become +127 .
The even-numbered bytes have 128 subtracted from them, and are assigned to quadrature1 .
Then a series of complex number are formed by pairing up the inphase1 values with corresponding quadrature1 locations.
Quadrature data is represented as complex values by convention.
0 commentaires
Voir également
Catégories
En savoir plus sur File Operations 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!