−2 −1 0 1 2 3
System Identification of an FIR filter
Time Index Signal Value Desired Output Error 0 5 10 15 20 25 30 35 −0.1 0 0.1 0.2 0.3 0.4 0.5 0.6 Coefficient # Coefficient Value Actual Estimated
Purpose
FIR adaptive filter that uses LMSSyntax
ha = adaptfilt.lms(l,step,leakage,coeffs,states)Description
ha = adaptfilt.lms(l,step,leakage,coeffs,states)constructs anFIR LMS adaptive filter objectha.
Input Arguments
Entries in the following table describe the input arguments for
adaptfilt.lms.
Input
Argument Description
l Adaptive filter length (the number of coefficients or
taps) and it must be a positive integer. ldefaults
to 10.
step LMS step size. It must be a nonnegative scalar. You
can usemaxstepto determine a reasonable range of
step size values for the signals being processed. step
defaults to 0.1.
leakage Your LMS leakage factor. It must be a scalar
between 0 and 1. Whenleakageis less than one, adaptfilt.lmsimplements a leaky LMS algorithm.
When you omit theleakageproperty in the calling
syntax, it defaults to 1 providing no leakage in the adapting algorithm.
coeffs Vector of initial filter coefficients. it must be a length lvector. coeffsdefaults to length lvector with
elements equal to zero.
states Vector of initial filter states for the adaptive filter.
It must be a lengthl-1 vector. statesdefaults to a
adaptfilt.lms
Properties
In the syntax for creating theadaptfiltobject, the input options areproperties of the object created. This table lists the properties for the
adaptfilt.lmsobject, their default values, and a brief description of
the property.
Property Range Property Description
Algorithm None Reports the adaptive filter
algorithm the object uses during adaptation
Coefficients Vector of
elements Vector containing the initialfilter coefficients. It must be a lengthlvector wherelis the
number of filter coefficients.
coeffsdefaults to a lengthl
vector of zeros when you do not provide the vector as an input argument.
FilterLength Any positive
integer Reports the length of the filter,the number of coefficients or taps
Leakage 0 to 1 LMS leakage factor. It must
be a scalar between zero and one. When it is less than one, a leaky NLMS algorithm results. leakagedefaults to 1
Property Range Property Description
PersistentMemory falseortrue Determine whether the filter
states and coefficients get restored to their starting values for each filtering operation. The starting values are the values in place when you create the filter.
PersistentMemoryreturns to
zero any property value that the filter changes during processing. Property values that the filter does not change are not affected. Defaults tofalse.
States Vector of
elements, data type double
Vector of the adaptive filter states. statesdefaults to a
vector of zeros which has length equal to (l- 1).
StepSize 0 to 1 LMS step size. It must be a
scalar between zero and one. Setting this step size value to one provides the fastest convergence. stepdefaults to
0.1.
Example
Use 500 iterations of an adapting filter system to identify and unknown 32nd-order FIR filter.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
mu = 0.008; % LMS step size.
ha = adaptfilt.lms(32,mu); [y,e] = filter(ha,x,d);
adaptfilt.lms
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;
Using LMS filters in an adaptive filter architecture is a time honored means for identifying an unknown filter. By running the example code provided you can demonstrate one process to identify an unknown FIR filter. 0 50 100 150 200 250 300 350 400 450 500 −2 −1 0 1 2 3
System Identification of an FIR Filter
Time Index Signal Value 0 5 10 15 20 25 30 35 −0.1 0 0.1 0.2 0.3 0.4 0.5 0.6 Coefficient # Coefficient Value Desired Output Error Actual Estimated
See Also
adaptfilt.blms, adaptfilt.blmsfft, adaptfilt.dlms,References
Shynk J.J., “Frequency-Domain and Multirate Adaptive Filtering,” IEEE Signal Processing Magazine, vol. 9, no. 1, pp. 14-37, Jan. 1992.adaptfilt.lsl
Purpose
Adaptive filter that uses LSLSyntax
ha = adaptfilt.lsl(l,lambda,delta,coeffs,states)Description
ha = adaptfilt.lsl(l,lambda,delta,coeffs,states)constructs aleast squares lattice adaptive filter ha.
Input Arguments
Entries in the following table describe the input arguments for
adaptfilt.lsl.
Input
Argument Description
l Length of the joint process filter coefficients. It
must be a positive integer and must be equal to the length of the prediction coefficients plus one. L defaults to 10.
lambda Forgetting factor of the adaptive filter. This is a
scalar and should lie in the range (0, 1]. lambda
defaults to 1. lambda= 1 denotes infinite memory
while adapting to find the new filter.
delta Soft-constrained initialization factor in the least
squares lattice algorithm. It should be positive.
deltadefaults to 1.
coeffs Vector of initial joint process filter coefficients. It
must be a lengthl vector. coeffsdefaults to a
lengthlvector of all zeros.
states Vector of the backward prediction error states of the
adaptive filter. statesdefaults to a lengthlvector
of all zeros, specifying soft-constrained initialization for the algorithm.
also input arguments for creatingadaptfilt.lslobjects. 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.
BkwdPrediction Returns the predicted
samples generated during adaptation. Refer to [2] in the bibliography for details about linear prediction.
Coefficients Vector of
elements Vector containing the initialfilter coefficients. It must be a length lvector where l is the number of filter
coefficients. coeffsdefaults
to lengthl vector of zeros
when you do not provide the argument for input.
FilterLength Any positive
integer Reports the length ofthe filter, the number of coefficients or taps.
ForgettingFactor 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 thelambdainput argument.
adaptfilt.lsl
Name Range Description
FwdPrediction Contains the predicted
values for samples during adaptation. Compare these to the actual samples to get the error and power.
InitFactor Soft-constrained
initialization factor. This scalar should be positive and sufficiently large to prevent an excessive number of Kalman gain rescues. delta
defaults to one.
PersistentMemory falseortrue 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.
PersistentMemoryreturns to
zero any state that the filter changes during processing. States that the filter does not change are not affected. Defaults tofalse.
States Vector of
elements, data type double
Vector of the adaptive filter states. statesdefaults to
a vector of zeros which has length equal tol.
Examples
Demonstrate Quadrature Phase Shift Keying (QPSK) adaptive equalization using a 32-coefficient adaptive filter running for 1000 iterations. After you review the example code, the figure shows the results of running the example to use QPSK adaptive equalization with a 32nd-order FIR filter. The error between the in-phase and quadrature components, as shown by the errors plotted in the upper plots, falls to near zero. Also, the equalized signal shows the clear quadrature nature.D = 16; % Number of samples of delay
b = exp(j*pi/4)*[-0.7 1]; % Numerator coefficients of channel
a = [1 -0.7]; % Denominator coefficients of channel
ntr= 1000; % Number of iterations
s = sign(randn(1,ntr+D))+j*sign(randn(1,ntr+D)); % QPSK signal
n = 0.1*(randn(1,ntr+D) + j*randn(1,ntr+D)); % Noise signal
r = filter(b,a,s)+n; % Received signal
x = r(1+D:ntr+D); % Input signal (received signal)
d = s(1:ntr); % Desired signal (delayed QPSK signal)
lam = 0.995; % Forgetting factor
del = 1; % initialization factor
ha = adaptfilt.lsl(32,lam,del); [y,e] = filter(ha,x,d);
subplot(2,2,1); plot(1:ntr,real([d;y;e])); title('In-Phase Components');
legend('Desired','Output','Error');
xlabel('Time Index'); ylabel('Signal Value'); subplot(2,2,2); plot(1:ntr,imag([d;y;e])); title('Quadrature Components');
legend('Desired','Output','Error');
xlabel('Time Index'); ylabel('Signal Value');
subplot(2,2,3); plot(x(ntr-100:ntr),'.'); axis([-3 3 -3 3]);
title('Received Signal Scatter Plot'); axis('square');
xlabel('Real[x]'); ylabel('Imag[x]'); grid on;
subplot(2,2,4); plot(y(ntr-100:ntr),'.'); axis([-3 3 -3 3]);
title('Equalized Signal Scatter Plot'); grid on;