Filter Design Toolbox    
adaptrls

Use a recursive least-squares (RLS) FIR adaptive filter in an adaptive filtering application

Syntax

Description

y = adaptrls(x,d,s) applies an FIR RLS adaptive filter to the data vector x and the desired signal d. The filtered data is returned in y. Structure s contains the RLS adaptive filter information that defines the algorithm being used. In addition, the final states of the adapted filter appear in s.states when you use s as an output argument.

Structure Element
initrls Element
Element Contents
s.coeffs
w0
RLS adaptive filter coefficients. Initialize s.coeffs with the initial values for the FIR filter coefficients. Updated filter coefficients after adapting are returned when s is an output argument.
s.invcov
p0
The inverse of the input covariance matrix. Initialize with the initial input covariance matrix inverse. The updated covariance matrix is returned when s is an output argument and you specify the 'direct' RLS algorithm.
s.lambda
lambda
The forgetting factor. Determines how the RLS algorithm handles past input data -- whether all data weighs equally in the algorithm or earlier data loses weight as it falls farther into the past.
s.states
zi
Returns the states of the FIR filter after adaptation. This is an optional element. If omitted, it defaults to a zero vector of length equal to the filter order. When you use adaptrls in a loop structure, use this element to specify the initial filter states for the adapting FIR filter.
s.gain

RLS algorithm gain value. Computed and returned after every iteration. This is a read-only value.
s.iter

Returns the total number of iterations in the adaptive filter run. Although you can set this in s, you should not. Consider it a read-only value.
s.alg
alg
Algorithm to use. Optional field. Can be one of 'direct' for the conventional RLS algorithm or 'sqrt' for the more stable square root (QR) method.

[y,e] = adaptrls(x,d,s) also returns the prediction error e. Ultimately this shows you how well the filter adapted to the desired signal and input data -- how well y approximates d.

[y,e,s] = adaptrls(x,d,s) returns the updated structure s.

In an application where the intermediate states are important, call this function in a "sample by sample mode" using a For-loop.

In lieu of assigning the strucure fields manually, the initrls function can be called to populate the structure S.

Examples

System Identification of a 32nd-order FIR filter (500 iterations). Identifying the characteristics of an unknown filter is a classic problem for adaptive filtering. This example uses an FIR filter as the unknown, and uses the RLS algorithm to calculate weights for the adapting filter. The stem plot that follows the example code demonstrates that the adapted filter matches the unknown quite closely.

Notice that the estimated filter misses on the actual coefficients between 15 and 20. By changing lambda from 1.0 to 0.9, we can make the actual and estimated match more closely, as shown in the next figure.

Algorithm

In vector form, the RLS algorithm, using exponential weighting, is]

where mk and Pk are defined as

Compared to the LMS algorithm used by adaptlms, adaptnlms, and others, the RLS algorithm can provide smaller error and faster convergence.

See Also

initrls, adaptkalman, adaptlms, adaptnlms, adaptsd, adaptse, adaptss

References

Haykin, S., Adaptive Filter Theory, Third Edition, Prentice-Hall, Inc., 1996.

A.H. Sayed and Kailath, T., "A State-space Approach to RLS Adaptive Filtering," IEEE Signal Processing Magazine, July 1994, pp. 18-60.


  adaptnlms adaptsd