Remove DC offset from input signal

181 Ansichten (letzte 30 Tage)
pulkit singh
pulkit singh am 4 Jul. 2019
Beantwortet: Raj am 5 Jul. 2019
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 Kommentare
Raj
Raj am 5 Jul. 2019
Can you share the text file? Is the DC offset a constant fixed value ?
pulkit singh
pulkit singh am 5 Jul. 2019
Hi Raj,
Please find the attached channeldata.txt file.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Raj
Raj am 5 Jul. 2019
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!!

Kategorien

Mehr zu Workspace Variables and MAT-Files finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by