Documentation |
FIR adaptive filter that uses window recursive least squares (RLS)
ha = adaptfilt.swrls(l,lambda,invcov,swblocklen,
dstates,...coeffs,states)
ha = adaptfilt.swrls(l,lambda,invcov,swblocklen,
dstates,...coeffs,states) constructs an FIR sliding
window 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.
Entries in the following table describe the input arguments for adaptfilt.swrls.
Input Argument | Description |
---|---|
l | Adaptive filter length (the number of coefficients or taps). It must be a positive integer. l defaults to 10. |
lambda | RLS forgetting factor. This is a scalar and should lie within the range (0, 1]. lambda defaults to 1. |
invcov | Inverse of the input signal covariance matrix. You should initialize invcov to a positive definite matrix. |
swblocklen | Block length of the sliding window. This integer must be at least as large as the filter length. swblocklen defaults to 16. |
dstates | Desired signal states of the adaptive filter. dstates defaults to a zero vector with length equal to (swblocklen - 1). |
coeffs | Vector of initial filter coefficients. It must be a length l vector. coeffs defaults to length l vector of all zeros. |
states | Vector of initial filter states. states defaults to a zero vector of length equal to (l + swblocklen - 2). |
Since your adaptfilt.swrls 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.swrls 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 | Any vector of 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. |
DesiredSignalStates | Vector | Desired signal states of the adaptive filter. dstates defaults to a zero vector with length equal to (swblocklen - 1). |
FilterLength | Any positive integer | Reports the length of the filter, the number of coefficients or taps |
ForgettingFactor | Scalar | Forgetting factor of the adaptive filter. This is a scalar and should lie in the range (0, 1]. It defaults to 1. Setting forgetting factor = 1 denotes infinite memory while adapting to find the new filter. Note that this is the lambda input argument. |
InvCov | Matrix | Square matrix with each dimension equal to the filter length l. |
KalmanGain | Vector with dimensions (l,1) | Empty when you construct the object, this gets populated after you run the filter. |
PersistentMemory | false or true | Determine whether the filter states get restored to their starting values for each filtering operation. The starting values are the values in place when you create the filter if you have not changed the filter since you constructed it. PersistentMemory returns to zero any state that the filter changes during processing. Defaults to false. |
States | Vector of elements, data type double | Vector of the adaptive filter states. states defaults to a vector of zeros which has length equal to (l + swblocklen - 2) |
SwBlockLength | Integer | Block length of the sliding window. This integer must be at least as large as the filter length. swblocklen defaults to 16. |
System Identification of a 32-coefficient FIR filter. Use 500 iterations to adapt to the unknown filter. After the example code, you see a figure that plots the results of the running the code.
x = randn(1,500); % Input to the filter b = fir1(31,0.5); % FIR system to be identified n = 0.1*randn(1,500); % Observation noise signal d = filter(b,1,x)+n; % Desired signal P0 = 10*eye(32); % Initial correlation matrix inverse lam = 0.99; % RLS forgetting factor N = 64; % Block length ha = adaptfilt.swrls(32,lam,P0,N); [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 the figure you see clearly that the adaptive filter process successfully identified the coefficients of the unknown FIR filter. You knew it had to or many things that you take for granted, such as modems on computers, would not work.