reading file in matlab

조회 수: 1 (최근 30일)
ali hassan
ali hassan 2020년 9월 21일
답변: Walter Roberson 2020년 9월 21일
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
ali hassan
ali hassan 2020년 9월 21일
where to put questions then??
Rik
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.
A quick Google search suggests this function is from this Git repository.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
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.

카테고리

Help CenterFile Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by