| Purpose |
| Sample per sample filtering and coefficient update using the Recursive Least Squares (RLS) Adaptive algorithm. |
| Syntax |
[w,y,e,R]=asptrls(x,w,d,R,a)
|
| Description |
asptrls() implements the recursive least squares adaptive algorithm used to update transversal adaptive filters. Referring to the general adaptive filter shown in Fig. 2.6, asptrls() takes an input samples delay line asptrls() is given by
The input and output parameters of asptrls() for an FIR adaptive filter of
Input Parameters [Size]::
x : vector of input samples at time n, [L x 1]
w : vector of filter coefficients w(n-1), [L x 1]
d : desired response d(n), [1 x 1]
R : last estimate of the inverse of the weighted
auto correlation matrix of x, [L x L]
a : forgetting factor, [1 x 1]
Output parameters::
w : updated filter coefficients w(n)
y : filter output y(n)
e : error signal, e(n)=d(n)-y(n)
R : updated R
|
| Example |
% RLS used in a simple system identification application. % By the end of this script the adaptive filter w % should have the same coefficients as the unknown filter h. iter = 5000; % Number of samples to process % Complex unknown impulse response h = [.9 + i*.4; 0.7+ i*.2; .5; .3+i*.1; .1]; xn = 2*(rand(iter,1)-0.5); % Input signal, zero mean random. % although xn is real, dn will be complex since h is complex dn = osfilter(h,xn); % Unknown filter output en = zeros(iter,1); % vector to collect the error % Initialize RLS with a filter of 10 coef. [w,x,d,y,e,R]=init_rls(10,0.1); %% Processing Loop for (m=1:iter) % update the input delay line x = [xn(m,:); x(1:end-1,:)]; |
d = dn(m,:) + 1e-3*rand; % additive noise of var = 1e-6 % call RLS to calculate the filter output, estimation error % and update the filter coefficients. [w,y,e,R]=asptrls(x,w,d,R,0.98); % save the last error sample to plot later en(m,:) = e; end; % display the results subplot(2,2,1);stem([real(w) imag(conj(w))]); grid; subplot(2,2,2); eb = filter(.1, [1 -.9], en .* conj(en)); plot(10*log10(eb ));gridRunning the above script will produce the graph shown in Fig. 4.17. The left side graph of the figure shows the adaptive filter coefficients after convergence which are almost identical to the unknown filter h. The right side graph shows the mean square error in dB versus time during the adaptation process, which is usually called the learning curve. The lower limit of the error power is governed here by the additive noise at the output (-60 dB).
|
| Remarks |
|
| Algorithm |
|
Unlike the LMS and its derivatives which use statistical (expected values) approach, the RLS is a deterministic algorithm based only on observed data. The practical implementation of the RLS algorithm adjusts the coefficients of an adaptive filter to minimize the following quantity
where asptrls() performs the following operations
|
| Resources |
The resources required to implement the RLS algorithm for a transversal adaptive FIR filter of
|
| See Also |
| INIT_ RLS, EQUALIZER_ RLS. |
| Reference |
| [2] and [4] for analysis of the RLS algorithm and its variants. |