git-svn-id: http://moon:8086/svn/matlab/trunk@153 801c6759-fa7c-4059-a304-17956f83a07c
61 lines
1.6 KiB
Matlab
Executable File
61 lines
1.6 KiB
Matlab
Executable File
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
% %
|
|
% RLS Algorithm %
|
|
% %
|
|
% Written By: Sundar Sankaran and A. A. (Louis) Beex %
|
|
% DSP Research Laboratory %
|
|
% Dept. of Electrical and Comp. Engg %
|
|
% Virginia Tech %
|
|
% Blacksburg VA 24061-0111 %
|
|
% %
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
randn('seed', 0) ;
|
|
rand('seed', 0) ;
|
|
|
|
NoOfData = 8000 ; % Set no of data points used for training
|
|
Order = 32 ; % Set the adaptive filter order
|
|
|
|
Lambda = 0.98 ; % Set the forgetting factor
|
|
Delta = 0.001 ; % R initialized to Delta*I
|
|
|
|
x = randn(NoOfData, 1) ;% Input assumed to be white
|
|
h = rand(Order, 1) ; % System picked randomly
|
|
d = filter(h, 1, x) ; % Generate output (desired signal)
|
|
|
|
% Initialize RLS
|
|
|
|
P = Delta * eye ( Order, Order ) ;
|
|
w = zeros ( Order, 1 ) ;
|
|
|
|
% RLS Adaptation
|
|
|
|
for n = Order : NoOfData ;
|
|
|
|
u = x(n:-1:n-Order+1) ;
|
|
pi_ = u' * P ;
|
|
k = Lambda + pi_ * u ;
|
|
K = pi_'/k;
|
|
e(n) = d(n) - w' * u ;
|
|
w = w + K * e(n) ;
|
|
PPrime = K * pi_ ;
|
|
P = ( P - PPrime ) / Lambda ;
|
|
w_err(n) = norm(h - w) ;
|
|
|
|
end ;
|
|
|
|
|
|
% Plot results
|
|
|
|
figure ;
|
|
plot(20*log10(abs(e))) ;
|
|
title('Learning Curve') ;
|
|
xlabel('Iteration Number') ;
|
|
ylabel('Output Estimation Error in dB') ;
|
|
|
|
figure ;
|
|
semilogy(w_err) ;
|
|
title('Weight Estimation Error') ;
|
|
xlabel('Iteration Number') ;
|
|
ylabel('Weight Error in dB') ;
|