Remove DC offset from input signal

조회 수: 57 (최근 30일)
pulkit singh
pulkit singh 2019년 7월 4일
답변: Raj 2019년 7월 5일
Hi
i have two data colunms( I and Q channel) in a tab delimited .txt file.
I need to remove DC offset from these channels and use them in QPSK demodulation code.
I am not a MATLAB guy. Please help me out.
  댓글 수: 2
Raj
Raj 2019년 7월 5일
Can you share the text file? Is the DC offset a constant fixed value ?
pulkit singh
pulkit singh 2019년 7월 5일
Hi Raj,
Please find the attached channeldata.txt file.

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

답변 (1개)

Raj
Raj 2019년 7월 5일
So basically you have an aperiodic set of data with unknown DC bias value. As I had asked, if the offset is a constant value then the easiest way out will be to just subtract the average value of your signal from the signal. This method basically assumes that the average value of the varying/AC component is zero over a period of time and average value of DC component is the same as it is constant. So when you take average of the signal (AC+DC component) what you basically end up getting is the DC offset. Then you can just subtract this DC offset value from your original signal.
Something like this:
%% Initialize variables.
filename = 'C:\Users\User\Documents\MATLAB\ChannelData.txt'; % Put your file path here
delimiter = '\t';
%% Format string for each line of text:
% column1: double (%f)
% column2: double (%f)
formatSpec = '%f%f%[^\n\r]';
%% Open the text file.
fileID = fopen(filename,'r');
%% Read columns of data according to format string.
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'ReturnOnError', false);
%% Close the text file.
fclose(fileID);
%% Allocate imported array to column variable names
Var1 = dataArray{:, 1};
Var2 = dataArray{:, 2};
%% Clear temporary variables
clearvars filename delimiter formatSpec fileID dataArray ans;
%% Subtract respective mean from each signal
Var3=Var1-mean(Var1);
Var4=Var2-mean(Var2);
Hope this helps!!

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by