www.pudn.com > myEqualizer.rar > myEqualizer.m


function myEqualizer 
 
randn('seed', 0) ; 
rand('seed', 0) ; 
  
%Variables% 
NoOfData = 8000 ;				% Set no of data points used for training 
Order = 15 ;					% Set the adaptive filter order 
Mu = 0.01 ;					% Set the step-size constant 
next=1;  
sizeOfIn=16;  
 
x=complex(randn(NoOfData,1),randn(NoOfData,1)); % Input assumed to be white 
h=complex(rand(Order, 1),rand(Order, 1));	% System picked randomly 
d = filter(h, 1, x) ;				% Generate output (desired signal) 
  
w=complex(zeros(Order+1,1),zeros(Order+1,1)); 
 
e = LMS_adaptive(sizeOfIn,NoOfData,Order,d,x,h,w); 
 
% Plot results 
%figure ; 
plot(20*log10(abs(e))) ;  
title('Learning Curve') ; 
xlabel('Iteration Number') ; 
ylabel('Output Estimation Error in dB') ; 
 
return; 
 
function e = LMS_adaptive( sizeOfIn,NoOfData,Order,d,x,h,w) 
 
%LMS Adaptation 
Mu = 0.01; 
 
e=complex(0,0); 
 
y=complex(zeros(NoOfData,1),zeros(NoOfData,1)); 
 
yI=0;yQ=0;eI=0;eQ=0;wI=0;wQ=0;xI=0;xQ=0; 
 
in=complex(zeros(sizeOfIn,1),zeros(sizeOfIn,1)); 
 
 
if 0 
 
for  n  = sizeOfIn : NoOfData 
 
     in=x(n:-1:n-sizeOfIn+1) ; 
 
     wI=real(w); 
 
     wQ=imag(w); 
 
     xQ=imag(in); 
 
     xI=real(in); 
 
     dI=real(d(n)); 
 
     dQ=imag(d(n));    
 
 
     y(n)=(wI'*xI + wQ'*xQ) + (wI'*xQ - wQ'*xI)*i;        
 
     yI=real(y(n)); 
 
     yQ=imag(y(n)); 
 
    
 
     %Error Calculation% 
 
     e(n)=(dI-yI) + (dQ-yQ)*i; 
 
 
 
     %Update Taps% 
 
     eI=real(e(n)); 
 
     eQ=imag(e(n)); 
 
     w=(wI + Mu* ( eI*xI + eQ*xQ ))  +  (wQ + Mu* ( eI*xQ - eQ*xI))*i; 
 
    
 
end ; 
end 
 
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 
if 1 
w=complex(zeros(Order,1),zeros(Order,1));     
for n = Order : NoOfData 
	D = x(n:-1:n-Order+1) ; 
	d_hat(n) = w'*D ; 
	e(n) = d(n) - d_hat(n) ; 
	w = w + Mu*conj(e(n))*D ; 
	w_err(n) = norm(h - w) ; 
end ; 
end 
 
return;