
remove DC offset for a interference signal
8 views (last 30 days)
Show older comments
Hi,
Could you please tell me how to remove DC offset for a interference signal?
I think the DC offset of my signal is not a constant.
Therefore, "signal-mean(signal)" is not quite accurate.
filename = ('waveform.xlsx');
data = xlsread(filename);
time = data(:,1);
signal = data(:,2);
0 Comments
Accepted Answer
Image Analyst
on 15 Dec 2021
Try this:
filename = ('waveform.xlsx');
data = xlsread(filename);
times = data(:,1);
signal = data(:,2);
% Plot it.
subplot(2, 1, 1);
plot(signal, 'b-')
% Find data points more than 1000 in value and fit a quaratic through them
mask = signal > 1000;
maskedTimes = times(mask);
maskedSignal = signal(mask);
coefficients = polyfit(maskedTimes, maskedSignal, 2);
% Get smoothed signal.
smoothedSignal = polyval(coefficients, times);
hold on;
plot(smoothedSignal, 'r-', 'LineWidth', 3)
grid on
% Now subtract the mean
signal2 = signal - smoothedSignal;
% Plot it.
subplot(2, 1, 2);
plot(signal2, 'b-')
% Plot line across the x axis
yline(0, 'LineWidth', 2)
grid on;

0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!