From: harika reddy lekkala on
Hi,
Here the problem I am facing is the weight updation values are not matching with the unknow plant values though the error is becoming is zero.......
Help me to find where the problem is? (it is working for two weights but not for 4, 8, 16 etc.......)

Thank u in advance.

close all;
clear all;
clc;
fm=input('enter the maximum frequency');
fs=20*fm;
n=input('enter the input sequence number');
for i=1:n,
x(i)=sin(2*pi*i*fm/fs);
end
w=[0.01 0.03 0.05 0.04];
lx=length(x);
lw=length(w);
w1=[w zeros(1, lw)]; %extended weght vector
Wf=fft(w1,2*lw); %fourier transform of extended weght vector
p=[1 -4 1 4];
d=conv(x,p);
x2=[zeros(1,lw) x(1:lw)]; %extednded input vector block length
X=fft(x2,2*lw); %fourier transform of extended input vector block length
Y=X.*Wf; % output in the frequency Domain
y=ifft(Y,2*lw); %output in the time domain
y1=y(lw+1:2*lw); % taking last L samples in the output which will match the linear convolution samples.
y2=y1;
for i=1:lw,
e(i)=d(i)-y1(i); % finding the error for L terms
end
e2=e;
e1=[zeros(1,lw) e]; % extended error vector
Ef=fft(e1); % fourier transform of error vector
H = conj(X).*Ef; % multiplication of conjugate of the FFT of the input vector and FFT of the error vector
h=ifft(H,2*lw);
h1=[h(1:lw) zeros(1,lw)];
H1=fft(h1,2*lw);
Wf= Wf+(2*(0.1/lw)*H1);
i=1;
while (((i-1)*lw)+(2*lw)<=lx)
x2= x(((i-1)*lw)+1 : ((i-1)*lw)+(2*lw));
X=fft(x2,2*lw);
Y=X.*Wf;
y=ifft(Y, 2*lw);
y1=y(lw+1:2*lw);
y2=[y2 y1];
for j=1:lw,
e(j)=d((i*lw)+j)-y1(j);
end
e2=[e2 e];
e1=[zeros(1,lw) e];
Ef=fft(e1);
H=conj(X).*Ef;
h=ifft(H,2*lw);
h1=[h(1:lw) zeros(1,lw)];
H1=fft(h1,2*lw);
Wf=Wf+(2*(0.1/lw)*H1);
i=i+1;
end
subplot(4,1,1);plot(x);
subplot(4,1,2);plot(d,'g');
subplot(4,1,3); plot(e2,'m');
subplot(4,1,4);plot(y2,'k');