Main Content

LMS Update

Estimate weights of LMS adaptive filter

  • Library:
  • DSP System Toolbox / Filtering / Adaptive Filters

  • LMS Update block

Description

TheLMS Updateblock estimates the weights of an LMS adaptive filter. Specify data and error as inputs and the block computes the filter weights based on the algorithm specified in theAlgorithm帕拉meter. For more details on the algorithms, seeAlgorithms.

You can configure the block to operate as a tapped-delay line FIR filter or as an adaptive linear combiner using theAdaptive filter mode帕拉meter. The block can also adapt multiple filters independently when you specify theNumber of adaptive filters帕拉meter to a value greater than 1.

You can use this block to compute the adaptive filter weights in applications such as system identification, inverse modeling, and filtered-x LMS algorithms, which are used in acoustic noise cancellation. For more details, seeReferences.

Ports

Input

expand all

Data input to the adaptive filter, specified as one of these:

  • Scalar –– When you set theAdaptive filter mode帕拉meter toTapped delay-line FIR filter, the input to the block should be a scalar.

    The block algorithm buffers the input samples to generate the vector u ( n ) = [ u ( n ) , u ( n 1 ) , ... , u ( n L + 1 ) ] , whereLis the length of the adaptive filter andnis the time index. The block algorithm then passes the vector through the filter.

  • Column vector of lengthL–– When you set theAdaptive filter mode帕拉meter toAdaptive linear combiner, the block does not buffer the input samples, and the input to the block should be in the form of a column vector. The block multiplies the vector with the filter weights to generate the filter output. In this case, there is no relationship between the input samples.

When you set theNumber of adaptive filters帕拉meter to a value greater than 1, the block assumes that all filters run on the same input.

When you set theAlgorithm帕拉meter toSign—Error LMS,Sign—Data LMS, orSign—Sign LMS, the data input through theInputport must be real.

Data Types:single|double
Complex Number Support:Yes

Specify the error between the output signal and the desired signal as a:

  • Scalar when the number of adaptive filtersN= 1.

  • Column vector of lengthNwhenN> 1.

When you set theAlgorithm帕拉meter toSign—Error LMS,Sign—Data LMS, orSign—Sign LMS, the error input through theErrorport must be real.

Data Types:single|double
Complex Number Support:Yes

Specify the filter adaptation step size as a scalar in the range [0,1].

Dependency

To enable this port, setStep size sourcetoInput port.

Data Types:single|double

The input to this port can be one of these:

  • 标量的数量,如果自适应滤波器(N)大于1,那么块更新filter weights for all filters if the value at the port is nonzero and does not update if the value at the port is 0.

  • Vector of lengthN–– If the number of adaptive filters (N) is greater than 1, then the block determines whether to update each filter during run time depending on the value of the corresponding element in theAdaptvector input. When theAdaptport input element is not 0, the block updates the filter weights. When the input is 0, the filter weights do not change.

For an example, seeAdapt Multiple Filters Using LMS Update block.

Dependency

To enable this port, select theEnable adapt input帕拉meter on the block dialog.

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

When the input to this port is not 0, the block resets the filter weights to their initial values. When the input to this port is 0, the filter weights do not change.

Dependency

To enable this port, select theEnable reset input帕拉meter on the block dialog.

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

Output

expand all

The block outputs the filter weights as a 1-by-Lrow vector or aN-by-Lmatrix, whereNis the number of adaptive filters, andLis the length of each filter.

Data Types:single|double

Parameters

expand all

The block uses one of the listed algorithms to compute the filter weights. For more details on the algorithms, seeAlgorithms.

Specify the length of each adaptive filterLas a positive integer.

When there areNadaptive filters, the weights vector the block generates through theWtsoutput port is anN-by-Lmatrix.

Specify the number of adaptive filtersNthe block supports as a positive integer.

When you specify this value to be an integer greater than 1, each filter can be chosen to adapt independently during run time by providing theAdaptinput as a logical vector of lengthN. All filters are assumed to run on the same input and have a common step size, leakage factor, and reset input.

The weights the block generates through theWtsoutput port is anN-by-Lmatrix, whereLis the length of each filter.

For an example that shows how to adapt multiple filters, seeAdapt Multiple Filters Using LMS Update block.

  • Property— Specify the filter adaptation size using theStep size (mu)帕拉meter.

  • Input port— Pass filter adaptation size using theMuinput port.

Step size (mu)indicates the amount by which the filter weights are updated in each iteration. Choose an optimal step size so that the filter is stable and the convergence speed is optimal.

这个参数是可调的。你可以改变它的价值e even during the simulation.

Tunable:Yes

Dependency

To enable this parameter, setStep size sourcetoProperty.

Leakage factor (0 to 1)prevents unbounded growth of the filter coefficients by reducing the drift of the coefficients from their optimum values. A leakage factor of1.0indicates no leakage. If you encounter coefficient drift, that is, large fluctuation about the optimum solution, decrease the leakage factor until the coefficient fluctuation becomes small.

这个参数是可调的。你可以改变它的价值e even during the simulation.

Tunable:Yes

Specify the initial value of filter weights as one of the following:

  • Scalar

  • Vector of size 1-by-L––Nis set to 1

  • Matrix of sizeN-by-L––N> 1 andL> 1

whereNis the number of adaptive filters specified inNumber of adaptive filtersandLis the length of each filter specified inFilter length.

This parameter specifies the initial value of the filter weightsw(n−1). The block uses this value to compute the weightsw(n), whenn= 1. For more information, seeAlgorithms.

Specify the adaptive filter mode as one of the following:

  • Tapped delay-line FIR filter–– The block assumes the variable portion of the adaptive filter to be a tapped delay-line FIR filter. In this mode, the input samples are related using this equation:

    u ( n ) = [ u ( n ) , u ( n 1 ) , ... , u ( n L + 1 ) ]

    wherenis the current time index andLis the length of the adaptive filter specified in theFilter length帕拉meter.

    The block accepts scalar input samples in this mode. The block algorithm buffers the samples to form theu(n) vector.

  • Adaptive linear combiner–– The block does not buffer the input samples, and the input you provide to the block must be a column vector equal in length to theFilter length帕拉meter. In this case, there is no relationship between the input samples.

For more details, seeAlgorithms.

When you select this check box, theAdaptinput port appears on the block. When the input to this port is greater than 0, the block updates the filter weights. When the input to this port is less than or equal to 0, the filter weights do not change.

When you select this check box, theResetinput port appears on the block. When the input to this port is greater than 0, the block resets the filter weights to their initial values. When the input to this port is less than or equal to 0, the filter weights do not change.

Specify the type of simulation to run as one of the following:

  • Code generation–– Simulate model using generated C code. The first time you run a simulation, Simulink®generates C code for the block. The C code is reused for subsequent simulations, as long as the model does not change. This option requires additional startup time but provides faster simulation speed thanInterpreted execution.

  • Interpreted execution–– Simulate model using the MATLAB®interpreter. This option shortens startup time but has slower simulation speed thanCode generation.

Block Characteristics

Data Types

double|single

Direct Feedthrough

no

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

no

Algorithms

expand all

In a closed loop adaptive filter, the weights or coefficients of the filter are adjusted until the error is minimized. The error is the difference between the filter output and the desired signal. In this block, the error signal is specified through theErrorinput port.

The block computes filter weight estimates using w ( n ) = α w ( n 1 ) + f ( u ( n ) , e ( n ) , μ ) .

The function f ( u ( n ) , e ( n ) , μ ) is defined according to the LMS algorithm you specify through theAlgorithm帕拉meter:

  • LMS f ( u ( n ) , e ( n ) , μ ) = μ e ( n ) u * ( n )

  • Normalized LMS f ( u ( n ) , e ( n ) , μ ) = μ e ( n ) u ( n ) ε + u H ( n ) u ( n )

    In theNormalized LMSalgorithm,εis a small positive constant that overcomes the potential numerical instability in the update of weights.

    For double-precision floating-point input, ε is the output of theepsfunction. For single-precision floating-point input, ε is the output ofeps("single"). For fixed-point input, ε is 0.

  • Sign-Error LMS f ( u ( n ) , e ( n ) , μ ) = μ sign ( e ( n ) ) u * ( n )

  • Sign-Data LMS f ( u ( n ) , e ( n ) , μ ) = μ e ( n ) sign ( u ( n ) ) , whereu(n) is real

  • Sign-Sign LMS f ( u ( n ) , e ( n ) , μ ) = μ sign ( e ( n ) ) sign ( u ( n ) ) , whereu(n) is real

In the equations:

  • n— The current time index.

  • u(n) — The vector of input samples at stepn.

    When you set theAdaptive filter mode帕拉meter toTapped delay-line FIR filter, the input to the block is a scalar value and the block buffers the input samples to generate theu(n) vector.

    When you set theAdaptive filter mode帕拉meter toAdaptive linear combiner, the block does not buffer the samples. The input to the block should be in the form of a column vector. In this case, there is no relationship between the input samples.

  • u*(n) — The complex conjugate of the vector of input samples at stepn.

  • w(n) — The vector of filter weight estimates at stepn.

  • e(n)— The estimation error at stepn.

  • µ— The adaptation step size.

  • α— The leakage factor (0 ≤ α ≤ 1).

References

[1] Madisetti, Vijay, and Douglas Williams. "Introduction to Adaptive Filters."The Digital Signal Processing Handbook.Boca Raton, FL: CRC Press, 1999.

[2] Akhtar, M. T., M. Abe, M. Kawamata. "Modified-filtered-x LMS algorithm based active noise control systems with improved online secondary-path modeling." IEEE Symposium on Circuits and Systems, 2004.

[3] Orfanidis, Sophocles J.Optimum Signal Processing. An Introduction. 2nd Ed. Englewood Cliffs, NJ: Prentice-Hall, 1996.http://eceweb1.rutgers.edu/%7Eorfanidi/osp2e/osp2e.pdf

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2016b