RLS算法在MATLAB上仿真实现的程序

发布网友 发布时间:2022-04-20 07:04

我来回答

1个回答

热心网友 时间:2022-07-13 04:24

% RLS 算法
<br>randn('seed', 0) ;
<br>rand('seed', 0) ;
<br>
<br>NoOfData = 8000 ; % Set no of data points used for training
<br>Order = 32 ; % Set the adaptive filter order
<br>
<br>Lambda = 0.98 ; % Set the forgetting factor
<br>Delta = 0.001 ; % R initialized to Delta*I
<br>
<br>x = randn(NoOfData, 1) ;% Input assumed to be white
<br>h = rand(Order, 1) ; % System picked randomly
<br>d = filter(h, 1, x) ; % Generate output (desired signal)
<br>
<br>% Initialize RLS
<br>
<br>P = Delta * eye ( Order, Order ) ;
<br>w = zeros ( Order, 1 ) ;
<br>
<br>% RLS Adaptation
<br>
<br>for n = Order : NoOfData ;
<br>
<br>u = x(n:-1:n-Order+1) ;
<br>pi_ = u' * P ;
<br>k = Lambda + pi_ * u ;
<br>K = pi_'/k;
<br>e(n) = d(n) - w' * u ;
<br>w = w + K * e(n) ;
<br>PPrime = K * pi_ ;
<br>P = ( P - PPrime ) / Lambda ;
<br>w_err(n) = norm(h - w) ;
<br>
<br>end ;
<br>
<br>% Plot results
<br>
<br>figure ;
<br>plot(20*log10(abs(e))) ;
<br>title('Learning Curve') ;
<br>xlabel('Iteration Number') ;
<br>ylabel('Output Estimation Error in dB') ;
<br>
<br>figure ;
<br>semilogy(w_err) ;
<br>title('Weight Estimation Error') ;
<br>xlabel('Iteration Number') ;
<br>ylabel('Weight Error in dB') ;
<br>
声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。
E-MAIL:11247931@qq.com