addaptive filter using least mean square algorithm

Status
Not open for further replies.

MahmoudHassan

Full Member level 6
Joined
Oct 4, 2010
Messages
349
Helped
44
Reputation
90
Reaction score
40
Trophy points
1,328
Activity points
3,913
hi
iam trying to make learning for coefficients of adaptive filter using least mean square algorithm

this is my code and it doesn't work




function adfilter()

i=0:.2:7; %discrete steps.
delta=.075; %delta step.
d=sin(i); %desired signal pure signal.
M=length(d);
N=5; %length of H
h=zeros(1,N); %H system cefficents.
e=10000;
x=d+.25* rand(1,length(d)); %x signal which is the desired signal with noise.
a=1;
es=zeros(10000);%error squared.


res=zeros(length(d));
while (a<100000) %iterations

for n=5:M
x1=x(n:-1:n-4);
y=h*x1';
res=y;
e=d-y;
h=h+delta*e*x1;

end
es=sum(e*e');
a=a+1;

end

subplot(3,2,1)
stem(d)
title('d')
subplot(3,2,2)
stem(res)
title('y')
subplot(3,2,3)
stem(h)
title('h')
subplot(3,2,4)
stem(x)
title('x+noise')
subplot(3,2,5:6)
plot(es)
title('error')
disp('Number of iterations:')
disp(a)
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…