| Filter Design Toolbox | ![]() |
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.
[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.
for n = 1:length(x) [y(n),e(n),s] = adaptrls(x(n),d(n),s); % States (The fields of S) here may be modified here. end
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.
x = 0.1*randn(1,500); % Desired signal. b = fir1(32,0.55); % FIR system to be identified. d = filter(b,1,x); % Input to the adapting filter. w0 = zeros(1,33); % Intial filter coefficients. p0 = 5*eye(33); % Initial input correlation matrix inverse. lambda = 1.0; % Exponential memory weighting factor. s = initrls(w0,p0,lambda); [y,e,s] = adaptrls(x,d,s); stem([b.',s.coeffs.']); legend('Actual','Estimated'); title('System Identification via RLS'); grid on;
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 | ![]() |