ourpro1.m
来自「ECG NOISE CANCELLATION IN MATLAB」· M 代码 · 共 56 行
M
56 行
clear all;
Fs = 1000;
N = 1000;
i = [0 : N-1]';
p=0.5*ecg(250).';
p1=[p;p;p;p];
p2=ecg(500).';
p3=[p2;p2];
figure;
subplot(311) ;plot(p3);
title('MATERNAL ECG SIGNAL');
x =p1+p3;
subplot(312) ;plot(x);
title('COMPOSITE SIGNAL');
y=x+sin(2*pi*60* i/Fs)
subplot(313);plot(y);
title('COMPOSITE SIGNAL WITH NOISE');
%create the reference signal of the adaptive filter
u =sin(2*pi*60* i/Fs);% sin(2*pi*60* i/Fs);
%adaptive filter architecture
L = 20;
step_size = 0.005;
w = zeros(1,L);
%run the adaptive filter
e(L) = x(L);
for k = L : N
regressor = flipud(u(k-L+ 1:k));
w = w + step_size * regressor' * e(k);
e(k+1) = y(k) - w * regressor;
end
%compute the spectrum of the initial signal and the filtered signal
f = [0 : Fs/N : Fs - Fs/N]';
F = abs(fft(y));
E = abs(fft(e));
%plot
figure;
subplot(211) ;plot(y); title(' COMPOSITE SIGNAL WITH NOISE');
subplot(212) ;plot(e); title('COMPOSITE SIGNAL AFTER FILTERING');
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?