
remove DC offset for a interference signal
7 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Image Analyst
2021-12-15
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 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!