
function[w,y,e,J,w1]=aaleakylms(x,dn,mu,gama,M)
%function[w,y,e,J,w1]=aaleakylms(x,dn,mu,gama,M)
%all signals are real valued;x=input to filter;
%y=output from the filter;dn=desired signal;
%mu=step-size factor;gama=gamma factor<<1;
%M=number of filter coefficients;w1=matrix whose M
%rows give the history of each filter coefficient;
N=length(x);
y=zeros(1,N);
w=zeros(1,M);
for n=M:N
    x1=x(n:-1:n-M+1);
    y(n)=w*x1';
    e(n)=dn(n)-y(n);
    w=(1-2*mu*gama)*w+2*mu*e(n)*x1;
    w1(n-M+1,:)=w(1,:);
end;
J=e.^2;