reading file in matlab
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Rik
2020-9-21
编辑:Rik
2020-9-21
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.
回答(1 个)
Walter Roberson
2020-9-21
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 File Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!