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;
fd=1;    % doppler frequency
fs=2560;        % sample frequency
Ns=fs/20;
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)
r=rayleigh_new(fd,fs,Ns);
y=filter(r,1,x);
d=awgn(y,20,'measured');
w=complex(zeros(Order+1,1),zeros(Order+1,1));
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));
%LMS Adaptation
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 ;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if 0
for n = Order : NoOfData
sizeof是什么
D = x(n:-1:n-Order+1) ;
d_hat(n) = w'*D ;
e(n) = d(n) - d_hat(n) ;
w = w + Mu*e(n)*D ;
w_err(n) = norm(h - w) ;
end ;
end
% Plot results
figure ;
plot(20*log10(abs(e))) ;
title('Learning Curve') ;
xlabel('Iteration Number') ;
ylabel('Output Estimation Error in dB') ;

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。