Remove DC offset from input signal

172 ビュー (過去 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 Center および File ExchangeWorkspace Variables and MAT-Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by