# LMS ALGORITHM to implement an adaptative filter

3 views (last 30 days)
Sara on 13 Dec 2011
I should implement an LMS algorithm for a FIR adaptative filter, to filter the signal ecg where ecg is primary input and is =v+m where v is the desired signal not correlated with r (noise reference input of the filter) m is the noise of the signal ecg correlated with r the LMS algorithm is:
N=10; %orden del filtro
mu=0.4; %parameter
w=zeros(1,N+1); %vector of filter coefficients
e=zeros(1,slen); %vector of error defines as the difference between the desired signal and the input reference signal to compute the filter coefficients to iteratively minimize the error
y=zeros(slen,1);
r=sin(2*pi*60*t); %input reference signal=noise 60 Hz
for n=N+1:slen
in=r(n-N:n);
y(n)=w*in';
e(n)=ecg(n)-y(n);
w=w+2*mu*e(n)*in;
end
d=filter(w,1,ecg); %desidered output of the adaptative filter
figure(2); plot(t,d);
the problem is that the output is add much more noise to the original ecg filter, instead of reduce it.. Someone can explain me where is/are the error/s..? Thank you very much!

Wayne King on 13 Dec 2011
What version of MATLAB are you using? Do you have the DSP System Toolbox, see the help adaptfilt.lms