Remove DC offset from input signal
135 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Raj
el 5 de Jul. de 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!!
0 comentarios
Ver también
Categorías
Más información sobre Audio and Video Data en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!