Remove DC offset from input signal
130 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
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!!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!