A. RLS演算法在MATLAB上模擬實現的程序
% 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>
B. 已知演算法 怎麼用Matlab進行模擬
按運行快捷鍵F5即可實現模擬圖。 MATLAB是美國MathWorks公司出品的商業數學軟體,用於演算法開發、數據可視化、數據分析以及數值計算的高級技術計算語言和互動式環境,主要包括MATLAB和Simulink兩大部分。 MATLAB是matrix&laboratory兩個詞的組合.