
function[w,y,e,J]=aalms(x,dn,mu,M)
%function[w,y,e,J]=aalms(x,dn,mu,M);
%all quantities are real-valued;
%x=input data to the filter; dn=desired signal;
%M=order of the filter;
%mu=step-size factor; x and dn must be of the same length;
N=length(x);
y=zeros(1,N); %initialized output of the filter;
w=zeros(1,M); %initialized filter coefficient vector;
for n=M:N
	x1=x(n:-1:n-M+1); %for each n the vector x1 is 
	                                %of length M with elements from x in reverse order;
	y(n)=w*x1';
	e(n)=dn(n)-y(n);
	w=w+2*mu*e(n)*x1;
end;
J=e.^2;%J is the learning curve of the adaptation;
