Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Topic: regarding the matlab code for lms algorithm
Replies: 0

 kannan r Posts: 4 Registered: 7/25/13
regarding the matlab code for lms algorithm
Posted: Jul 25, 2013 4:18 AM

actually the code that i got from file exchange lms.m i could not understand the block diagram properly and whether the error signal should be equal to the signal without noise or not is still unclear and whether the estimated speech signal that is the filter output should be equal to the clean signal ?in this code there are 2 signals 1)signal+noise
2) only signal without noise
this is the lms code i have got it and i have modified the code to some extent . Here the modification done is by adding the function filter2.Whether i am going on the right track or not i want clarification from anybody of you?
clc
close all
clear all

N=2000;
%input('length of sequence N = ');
t=[0:N-1];

w0=0.001; phi=0.1;
d=sin(2*pi*[1:N]*w0+phi);
n=randn(1,N)*0.5;
x=d+n;

w=zeros(1,N);
mu=0.089;
for i=1:N
e(i) = d(i) - w(i)' * x(i);
w(i+1) = w(i) + mu * e(i) * x(i);
end
for i=1:N
yd(i) = sum(w(i)' * x(i));
end
yd=yd+1;
dd=filter2(yd,d);
dd=0+dd;
dd1=filter2(yd,n');
j=1:length(d);
subplot(511),plot(j,d);
subplot(512),plot(j,n);
subplot(513),plot(j,yd);
subplot(514),plot(j,dd);
subplot(515),plot(j,dd1);