3
adaptfilt.rls Recursive least-squares FIR adaptive filter Syntax ha = adaptfilt.rls(l,lambda,invcov,coeffs,states) Description ha = adaptfilt.rls(l,lambda,invcov,coeffs,states) constructs an FIR direct form RLS adaptive filter ha. For information on how to run data through your adaptive filter object, see the Adaptive Filter Syntaxes section of the reference page for filter. Input Arguments Entries in the following table describe the input arguments for adaptfilt.rls. Input Argument Description l Adaptive filter length (the number of coefficients or taps) and it must be a positive integer. l defaults to 10. lambda RLS forgetting factor. This is a scalar and should lie in the range (0, 1]. lambda defaults to 1. invcov Inverse of the input signal covariance matrix. For best performance, you should initialize this matrix to be a positive definite matrix. coeffs Vector of initial filter coefficients. it must be a length l vector. coeffs defaults to length l vector with elements equal to zero. states Vector of initial filter states for the adaptive filter. It must be a length l-1 vector. states defaults to a length l-1 vector of zeros. Properties Since your adaptfilt.rls filter is an object, it has properties that define its behavior in operation. Note that many of the properties are also input arguments for creating adaptfilt.rls objects. To show you the properties that apply, this table lists and describes each property for the filter object. Name Range Description Algorithm None Defines the adaptive filter algorithm the object uses during adaptation. Coefficients Vector containing l elements Vector containing the initial filter coefficients. It must be a length l vector where l is the number of filter coefficients. coeffs defaults to length l vector of zeros when you do not provide the argument for input. FilterLength Any positive integer Reports the length of the filter, the number of coefficients or taps. Remember that filter length is filter order + 1. ForgettingFactor Scalar Forgetting factor of the adaptive filter. This is a scalar

Recursive Least-squares FIR Adaptive Filter - MATLAB Adaptfilt

Embed Size (px)

DESCRIPTION

red

Citation preview

Page 1: Recursive Least-squares FIR Adaptive Filter - MATLAB Adaptfilt

adaptfilt.rlsRecursive least-squares FIR adaptive filter

Syntaxha = adaptfilt.rls(l,lambda,invcov,coeffs,states)

Description

ha = adaptfilt.rls(l,lambda,invcov,coeffs,states) constructs an FIR direct form RLS adaptive filter ha.

For information on how to run data through your adaptive filter object, see the Adaptive Filter Syntaxessection of the reference page for filter.

Input ArgumentsEntries in the following table describe the input arguments for adaptfilt.rls.

Input Argument Description

l Adaptive filter length (the number of coefficients or taps) and it must be apositive integer. l defaults to 10.

lambda RLS forgetting factor. This is a scalar and should lie in the range (0, 1]. lambdadefaults to 1.

invcov Inverse of the input signal covariance matrix. For best performance, youshould initialize this matrix to be a positive definite matrix.

coeffs Vector of initial filter coefficients. it must be a length l vector. coeffs defaultsto length l vector with elements equal to zero.

states Vector of initial filter states for the adaptive filter. It must be a length l-1 vector.states defaults to a length l-1 vector of zeros.

Properties

Since your adaptfilt.rls filter is an object, it has properties that define its behavior in operation. Note thatmany of the properties are also input arguments for creating adaptfilt.rls objects. To show you theproperties that apply, this table lists and describes each property for the filter object.

Name Range Description

Algorithm None Defines the adaptive filter algorithm the object usesduring adaptation.

Coefficients Vector containing lelements

Vector containing the initial filter coefficients. It mustbe a length l vector where l is the number of filtercoefficients. coeffs defaults to length l vector of zeroswhen you do not provide the argument for input.

FilterLength Any positive integer Reports the length of the filter, the number ofcoefficients or taps. Remember that filter length is filterorder + 1.

ForgettingFactor Scalar Forgetting factor of the adaptive filter. This is a scalar

Page 2: Recursive Least-squares FIR Adaptive Filter - MATLAB Adaptfilt

ForgettingFactor Scalar Forgetting factor of the adaptive filter. This is a scalarand should lie in the range (0, 1]. It defaults to 1.

Setting forgetting factor = 1 denotes infinitememory while adapting to find the new filter. Note thatthis is the lambda input argument.

InvCov Matrix of size l-by-l

Upper-triangular Cholesky (square root) factor of theinput covariance matrix. Initialize this matrix with apositive definite upper triangular matrix.

KalmanGain Vector of size (l,1) Empty when you construct the object, this getspopulated after you run the filter.

PersistentMemory false or true Determine whether the filter states get restored to theirstarting values for each filtering operation. The startingvalues are the values in place when you create thefilter if you have not changed the filter since youconstructed it. PersistentMemory returns to zero anystate that the filter changes during processing.Defaults to false.

States Double array Vector of the adaptive filter states. states defaults to avector of zeros which has length equal to (l +projectord - 2).

Examples

System Identification of a 32-coefficient FIR filter over 500 adaptation iterations.

x = randn(1,500); % Input to the filterb = fir1(31,0.5); % FIR system to be identifiedn = 0.1*randn(1,500); % Observation noise signald = filter(b,1,x)+n; % Desired signalP0 = 10*eye(32); % Initial sqrt correlation matrix inverselam = 0.99; % RLS forgetting factorha = adaptfilt.rls(32,lam,P0);[y,e] = filter(ha,x,d);subplot(2,1,1); plot(1:500,[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([b.',ha.Coefficients.']);legend('Actual','Estimated');xlabel('Coefficient #'); ylabel('Coefficient valUe'); grid on;

In this example of adaptive filtering using the RLS algorithm to update the filter coefficients for each iteration,the figure shown reveals the fidelity of the derived filter after adaptation.