dsp.RLSFilter

Compute output, error and coefficients using recursive least squares (RLS) algorithm

Description

The dsp.RLSFilter System object™ filters each channel of the input using RLS filter implementations.

To filter each channel of the input:

  1. Create the dsp.RLSFilter object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects? (MATLAB).

Creation

Syntax

rlsFilt = dsp.RLSFilter
rlsFilt = dsp.RLSFilter(len)
rlsFilt = dsp.RLSFilter(Name,Value)

Description

rlsFilt = dsp.RLSFilter returns an adaptive RLS filter System object, rlsFilt. This System object computes the filtered output, filter error, and the filter weights for a given input and desired signal using the RLS algorithm.

example

rlsFilt = dsp.RLSFilter(len) returns an RLS filter System object, rlsFilt. This System object has the Length property set to len.

rlsFilt = dsp.RLSFilter(Name,Value) returns an RLS filter System object with each specified property set to the specified value. Enclose each property name in single quotes. Unspecified properties have default values.

Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects (MATLAB).

You can specify the method used to calculate filter coefficients as Conventional RLS [1] [2], Householder RLS [3] [4], Sliding-window RLS [5][1][2], Householder sliding-window RLS [4], or QR decomposition [1] [2]. This property is nontunable.

Specify the length of the RLS filter coefficients vector as a scalar positive integer value. This property is nontunable.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Specify the width of the sliding window as a scalar positive integer value greater than or equal to the Length property value. This property is nontunable.

Dependencies

This property applies only when the Method property is set to Sliding-window RLS or Householder sliding-window RLS.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Specify the RLS forgetting factor as a scalar positive numeric value less than or equal to 1. Setting this property value to 1 denotes infinite memory, while adapting to find the new filter.

Tunable: Yes

Data Types: single | double

Specify the initial values of the FIR adaptive filter coefficients as a scalar or a vector of length equal to the Length property value.

Tunable: Yes

Data Types: single | double

Specify the initial values of the inverse covariance matrix of the input signal. This property must be either a scalar or a square matrix, with each dimension equal to the Length property value. If you set a scalar value, the InverseCovariance property is initialized to a diagonal matrix with diagonal elements equal to that scalar value.

Tunable: Yes

Dependencies

This property applies only when the Method property is set to Conventional RLS or Sliding-window RLS.

Data Types: single | double

Specify the initial values of the square root inverse covariance matrix of the input signal. This property must be either a scalar or a square matrix with each dimension equal to the Length property value. If you set a scalar value, the SquareRootInverseCovariance property is initialized to a diagonal matrix with diagonal elements equal to that scalar value.

Tunable: Yes

Dependencies

This property applies only when the Method property is set to Householder RLS or Householder sliding-window RLS.

Data Types: single | double

Specify the initial values of the square root covariance matrix of the input signal. This property must be either a scalar or a square matrix with each dimension equal to the Length property value. If you set a scalar value, the SquareRootCovariance property is initialized to a diagonal matrix with diagonal elements equal to the scalar value.

Tunable: Yes

Dependencies

This property applies only when the Method property is set to QR-decomposition RLS.

Data Types: single | double

Specify whether the filter coefficient values should be locked. When you set this property to true, the filter coefficients are not updated and their values remain the same. The default value is false (filter coefficients continuously updated).

Tunable: Yes

Usage

For versions earlier than R2016b, use the step function to run the System object algorithm. The arguments to step are the object you created, followed by the arguments shown in this section.

For example, y = step(obj,x) and y = obj(x) perform equivalent operations.

Syntax

y = rlsFilt(x,d)
[y,e] = rlsFilt(x,d)

Description

example

y = rlsFilt(x,d) recursively adapts the reference input, x, to match the desired signal, d, using the System object, rlsFilt. The desired signal, d, is the signal desired plus some undesired noise.

[y,e] = rlsFilt(x,d) shows the output of the RLS filter along with the error, e, between the reference input and the desired signal. The filters adapts its coefficients until the error e is minimized. You can access these coefficients by accessing the Coefficients property of the object. This can be done only after calling the object. For example, to access the optimized coefficients of the rlsFilt filter, call rlsFilt.Coefficients after you pass the input and desired signal to the object.

Input Arguments

expand all

The signal to be filtered by the RLS filter. The input, x, and the desired signal, d, must have the same size and data type.

The input can be a variable-size signal. You can change the number of elements in the column vector even when the object is locked. The System object locks when you call the object to run its algorithm.

Data Types: single | double
Complex Number Support: Yes

The RLS filter adapts its coefficients to minimize the error, e, and converge the input signal x to the desired signal d as closely as possible.

The input, x, and the desired signal, d, must have the same size and data type.

The desired signal, d, can be a variable-size signal. You can change the number of elements in the column vector even when the object is locked. The System object locks when you call the object to run its algorithm.

Data Types: single | double
Complex Number Support: Yes

Output Arguments

expand all

Filtered output, returned as a scalar or a column vector. The object adapts its filter coefficients to converge the input signal x to match the desired signal d. The filter outputs the converged signal.

Data Types: single | double
Complex Number Support: Yes

Difference between the output signal y and the desired signal d, returned as a scalar or a column vector. The objective of the RLS filter is to minimize this error. The object adapts its coefficients to converge toward optimal filter coefficients that produce an output signal that matches closely with the desired signal. For more details on how e is computed, see Algorithms. To access the RLS filter coefficients, call rlsFilt.Coefficients after you pass the input and desired signal to the object.

Data Types: single | double
Complex Number Support: Yes

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)

expand all

msesimEstimated mean squared error for adaptive filters
stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

expand all

Use the RLS filter System object™ to determine the signal value.

Note: If you are using R2016a or an earlier release, replace each call to the object with the equivalent step syntax. For example, obj(x) becomes step(obj,x).

rls1 = dsp.RLSFilter(11, 'ForgettingFactor', 0.98);
filt = dsp.FIRFilter('Numerator',fir1(10, .25)); % Unknown System
x = randn(1000,1);                       % input signal
d = filt(x) + 0.01*randn(1000,1); % desired signal
[y,e] = rls1(x, d);
w = rls1.Coefficients;
subplot(2,1,1), plot(1:1000, [d,y,e]);
title('System Identification of an FIR filter');
legend('Desired', 'Output', 'Error');
xlabel('time index'); ylabel('signal value');
subplot(2,1,2); stem([filt.Numerator; w].');
legend('Actual','Estimated');
xlabel('coefficient #'); ylabel('coefficient value');

Noise Cancellation

rls2 = dsp.RLSFilter('Length', 11, 'Method', 'Householder RLS');
filt2 = dsp.FIRFilter('Numerator',fir1(10, [.5, .75]));
x = randn(1000,1);                           % Noise
d = filt2(x) + sin(0:.05:49.95)';     % Noise + Signal
[y, err] = rls2(x, d);
subplot(2,1,1), plot(d), title('Noise + Signal');
subplot(2,1,2), plot(err), title('Signal');

Algorithms

The dsp.RLSFilter System object, when Conventional RLS is selected, recursively computes the least squares estimate (RLS) of the FIR filter weights. The System object estimates the filter weights or coefficients, needed to convert the input signal into the desired signal. The input signal can be a scalar or a column vector. The desired signal must have the same data type, complexity, and dimensions as the input signal. The corresponding RLS filter is expressed in matrix form as P(n) :

k(n)=λ1P(n1)u(n)1+λ1uH(n)P(n1)u(n)y(n)=wT(n1)u(n)e(n)=d(n)y(n)w(n)=w(n1)+k(n)e(n)P(n)=λ1P(n1)λ1k(n)uH(n)P(n1)

where λ-1 denotes the reciprocal of the exponential weighting factor. The variables are as follows:

VariableDescription
nThe current time index
u(n)The vector of buffered input samples at step n
P(n)The inverse correlation matrix at step n
k(n)The gain vector at step n
w(n)The vector of filter tap estimates at step n
y(n)The filtered output at step n
e(n)The estimation error at step n
d(n)The desired response at step n
λThe forgetting factor

u, w, and k are all column vectors.

References

[1] M Hayes, Statistical Digital Signal Processing and Modeling, New York: Wiley, 1996.

[2] S. Haykin, Adaptive Filter Theory, 4th Edition, Upper Saddle River, NJ: Prentice Hall, 2002 .

[3] A.A. Rontogiannis and S. Theodoridis, "Inverse factorization adaptive least-squares algorithms," Signal Processing, vol. 52, no. 1, pp. 35-47, July 1996.

[4] S.C. Douglas, "Numerically-robust O(N2) RLS algorithms using least-squares prewhitening," Proc. IEEE Int. Conf. on Acoustics, Speech, and Signal Processing, Istanbul, Turkey, vol. I, pp. 412-415, June 2000.

[5] A. H. Sayed, Fundamentals of Adaptive Filtering, Hoboken, NJ: John Wiley & Sons, 2003.

Extended Capabilities

Introduced in R2013a