Compute output, error, and weights of LMS adaptive filter
The dsp.LMSFilter
System
object™ implements an adaptive finite impulse response (FIR) filter that converges an
input signal to the desired signal using one of the following algorithms:
LMS
Normalized LMS
Sign-Data LMS
Sign-Error LMS
Sign-Sign LMS
For more details on each of these methods, see Algorithms.
The filter adapts its weights until the error between the primary input signal and the
desired signal is minimal. The mean square of this error (MSE) is computed using the msesim
function. The
predicted version of the MSE is determined using a Wiener filter in the msepred
function.
The maxstep
function
computes the maximum adaptation step size, which controls the speed of convergence.
To filter a signal using an adaptive FIR filter:
Create the dsp.LMSFilter
object and set its properties.
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).
lms = dsp.LMSFilter
lms = dsp.LMSFilter(L)
lms = dsp.LMSFilter(Name,Value)
returns an LMS filter
object, lms
= dsp.LMSFilterlms
, that computes the filtered output, filter
error and the filter weights for a given input and a desired signal using the least mean
squares (LMS) algorithm.
lms = dsp.LMSFilter(
returns an
LMS filter object with each specified property set to the specified value. Enclose each
property name in single quotes. You can use this syntax with the previous input
argument.Name,Value
)
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.
[y,err,wts] = lms(x,d)
[y,err] = lms(x,d)
[___] = lms(x,d,mu)
[___] = lms(x,d,a)
[___] = lms(x,d,r)
[y,err,wts] = lms(x,d,mu,a,r)
[
filters the input signal, y
,err
,wts
] = lms(x
,d
)x
, using d
as the
desired signal, and returns the filtered output in y
, the filter
error in err
, and the estimated filter weights in
wts
. The lms filter object estimates the filter weights needed to
minimize the error between the output signal and the desired signal.
[
filters the input signal, y
,err
] = lms(x
,d
)x
, using d
as the
desired signal, and returns the filtered output in y
and the filter
error in err
when the WeightsOutput property is set to
'None'
.
[___] = lms(
filters the input signal, x
,d
,mu
)x
, using d
as the
desired signal and mu
as the step size, when the StepSizeSource property is set to 'Input
port'
. These inputs can be used with either of the previous sets of
outputs.
[___] = lms(
filters the input signal, x
,d
,a
)x
, using d
as the
desired signal and a
as the adaptation control when the AdaptInputPort property is set to
true
. When a
is nonzero, the System
object continuously updates the filter weights. When a
is
zero, the filter weights remain constant.
[___] = lms(
filters the input signal, x
,d
,r
)x
, using d
as the
desired signal and r
as a reset signal when the WeightsResetInputPort property is set to
true
. The WeightsResetCondition property can be used to set the
reset trigger condition. If a reset event occurs, the System
object resets the filter weights to their initial values.
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)
The LMS filter algorithm is defined by the following equations.
$$\begin{array}{c}y(n)={w}^{T}(n-1)u(n)\\ e(n)=d(n)-y(n)\\ w(n)=\alpha w(n-1)+f(u(n),e(n),\mu )\end{array}$$
The various LMS adaptive filter algorithms available in this System object are defined as:
LMS:
$$f(u(n),e(n),\mu )=\mu e(n){u}^{*}(n)$$
Normalized LMS:
$$f(u(n),e(n),\mu )=\mu e(n)\frac{{u}^{\ast}(n)}{\epsilon +{u}^{H}(n)u(n)}$$
In Normalized LMS, to overcome potential numerical instability in the update of the weights, a small positive constant, ε, has been added in the denominator. For double-precision floating-point input, ε is 2.2204460492503131e-016. For single-precision floating-point input, ε is 1.192092896e-07. For fixed-point input, ε is 0.
Sign-Error LMS:
$$f(u(n),e(n),\mu )=\mu \text{sign}(e(n)){u}^{*}(n)$$
Sign-Data LMS:
$$f(u(n),e(n),\mu )=\mu e(n)\text{sign}(u(n))$$
where u(n) is real.
Sign-Sign LMS:
$$f(u(n),e(n),\mu )=\mu \text{sign}(e(n))\text{sign}(u(n))$$
where u(n) is real.
The variables are as follows:
Variable | Description |
---|---|
n |
The current time index |
u(n) |
The vector of buffered input samples at step n |
u*(n) |
The complex conjugate of the vector of buffered input samples at step n |
w(n) |
The vector of filter weight 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 adaptation step size |
α | The leakage factor (0 < α ≤ 1) |
ε | A constant that corrects any potential numerical instability that occurs during the update of weights. |
[1] Hayes, M.H. Statistical Digital Signal Processing and Modeling. New York: John Wiley & Sons, 1996.
dsp.AdaptiveLatticeFilter
| dsp.AffineProjectionFilter
| dsp.BlockLMSFilter
| dsp.FIRFilter
| dsp.FastTransversalFilter
| dsp.FilteredXLMSFilter
| dsp.FrequencyDomainAdaptiveFilter
| dsp.KalmanFilter
| dsp.RLSFilter