Forums

lms notch adaptive filter

Started by el01...@mail.ntua.gr February 26, 2008
hello,
>
>im new to the topic of adaptive filters and its implementation in matlab. im doing a project on 'filtering an ECG foetus'. we are carrying out all our analysis on an ECG wave with only a powerline interference (60hz).
>
>the signal available to us is an ECG wave with a noise component of 60hz, sampled at 360hz..
>can you help me implement an adaptive filter using LMS algorithm for this signal in matlab... i am not clear with regards to the value of mu(step size), filter order, necessary inputs to be given to filter etc... can someone please send me a SAMPLE CODE.
>
>thanks
>
>**********************************************************
Hello,
this is a simulation of the application, in which you are interested. Instead of an ECG signal i use a simpler one, containing one component at 200Hz, one at 280Hz, one at 60Hz plus white noise. In the sequel i design an lms adaptive filter which removes the 60Hz component from the initial signal. The filtered signal is the "error signal e" of the adaptive filter. Please, study, run and experiment with the code:

clear all

Fs = 1000;
N = 1000;
i = [0 : N-1]';

%create the initial signal
x = sin(2*pi*200*i/Fs) + 0.66*sin(2*pi*280*i/Fs) + 0.59*sin(2*pi*60*i/Fs) + 0.5^0.5*randn(N,1);

%create the reference signal of the adaptive filter
u = 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) = x(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(x));
E = abs(fft(e));

%plot
figure;
subplot(411);plot(x);title('initial signal');
subplot(412);plot(e);title('initial signal after filtering');
subplot(413);plot(f,F(1:length(f)));title('spectrum of initial signal');
subplot(414);plot(f,E(1:length(f)));title('spectrum of initial signal after filtering');