Main Content

Block LMS Filter

Compute output, error, and weights using LMS adaptive algorithm

  • Block LMS Filter block

Libraries:
DSP System Toolbox / Filtering / Adaptive Filters

Description

The Block LMS Filter block implements an adaptive least mean-square (LMS) filter, where the adaptation of filter weights occurs once for every block of samples. The block estimates the filter weights (also known as the coefficients) needed to minimize the error e(n) between the output signal y(n) and the desired signal d(n). For more information, see Algorithms. For more information on adaptive filters, see Overview of Adaptive Filters and Applications.

Ports

Input

expand all

Specify the input signal you want to filter as a scalar or a column vector.

The input signal and the desired signal must have the same size, data type, and complexity.

The input frame length (number of rows in the input) must be an integer multiple of the value you specify in the Block size parameter.

Data Types: single | double
Complex Number Support: Yes

Specify the signal you want to model as a scalar or a column vector. The LMS filter adapts its coefficients to minimize the error and converge the input signal to the desired signal as closely as possible.

The input signal and the desired signal must have the same size, data type, and complexity.

Data Types: single | double
Complex Number Support: Yes

Specify the adaptation step size as a nonnegative scalar. The data type of the step size input must match the data type of the input signal and the desired signal.

A small step size ensures a small steady state error between the output signal and the desired signal. If the step size is small, the convergence speed of the filter decreases. To improve the convergence speed, increase the step size. Note that if the step size is large, the filter can become unstable.

Dependencies

To enable this port, set Specify step size via to 'Input port'.

Data Types: single | double

Specify the block to update filter weights. If the value of this input is nonzero, the block continuously updates the filter weights. If the value of this input is zero, the filter weights remain at their current values.

Dependencies

To enable this port, select the Adapt port check box.

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

Specify the reset signal as a scalar signal. When you want to reset the value of the filter weights to their initial values, use the Reset port parameter. The block resets the filter weights whenever a reset event is detected at the Reset port. The reset signal rate must be the same rate as the data signal input.

To enable the Reset port, select one of the following from the Reset port list:

  • Rising edge — Triggers a reset operation when the Reset input does one of the following:

    • Rises from a negative value to a positive value or zero

    • Rises from zero to a positive value, where the rise is not a continuation of a rise from a negative value to zero

      See the following figure:

  • Falling edge — Triggers a reset operation when the Reset input does one of the following:

    • Falls from a positive value to a negative value or zero

    • Falls from zero to a negative value, where the fall is not a continuation of a fall from a positive value to zero

      See the following figure:

  • Either edge — Triggers a reset operation when the Reset input is a Rising edge or Falling edge

  • Non-zero sample — Triggers a reset operation at each sample time that the Reset input is not zero

To disable the reset port, set Reset port to None.

Dependencies

To enable this port, set Reset port to any option other than None.

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

Output

expand all

Filtered signal, returned as a scalar or a column vector. The block adapts its filter coefficients to converge the input signal to match the desired signal. The filter outputs the converged signal. For more information on how the block computes the output, see Algorithms.

Data Types: single | double
Complex Number Support: Yes

Difference between the filtered signal and the desired signal, returned as a scalar or a column vector. The objective of the LMS filter is to minimize this error. The block adapts its coefficients to converge towards optimal filter coefficients that produce an output signal that matches closely with the desired signal. For more information on how the block computes the error, see Algorithms.

Data Types: single | double
Complex Number Support: Yes

Weights of the LMS filter, returned as a column vector of length equal to the value you specify in the Filter length parameter. For each iteration, the block outputs the current updated filter weights from this port. For more information on how the block updates the filter weights, see Algorithms.

The data type of the filter weights matches the data type of the filtered signal.

Dependencies

To enable this port, select the Output filter weights check box.

Data Types: single | double
Complex Number Support: Yes

Parameters

expand all

Specify the length of the FIR filter coefficients vector as a positive integer.

Specify the number of samples of the input signal to acquire before the block updates the filter weights as a positive integer. The input frame length (number of rows in the input) must be an integer multiple of the value you specify in this parameter.

Specify the adaptation step size through:

  • Dialog –– Use the Step size (mu) parameter to specify the step size in the block dialog box.

  • Input port –– Use the Step-size input port to specify the step size.

Specify the adaptation step size µ as a nonnegative integer. You can specify the step size using the input port, Step-size, or enter a value in this parameter.

A small step size ensures a small steady state error between the output signal and the desired signal. If the step size is small, the convergence speed of the filter decreases. To improve the convergence speed, increase the step size. Note that if the step size is large, the filter can become unstable.

Tunable: Yes

Dependencies

To enable this parameter, set the Specify step size via parameter to Dialog.

Specify the leakage factor used in the leaky LMS algorithm shown below as a scalar in the range [0, 1], 0<1μα1.

w(k)=(1μα)w(k1)+f(u(n),e(n),μ)

When the value is less than 1, the block implements a leaky LMS algorithm. The default is 1, providing no leakage in the adapting algorithm.

Tunable: Yes

Specify initial values of the filter weights as a scalar or a vector of length equal to the filter length. When you specify a scalar, the block uses the scalar value to create a vector of filter weights. This vector has length equal to the filter length and all of its values are equal to the scalar value.

Select this check box to enable the Adapt input port. Through this port, you can specify the block to update its filter weights or to keep them at the current level. For more information, see the description of the Adapt input port.

Select this check box to enable the Reset input port. For more information on each of the reset options, see the description for the Reset input port.

Select this check box to export the filter weights from the Wts port.

Block Characteristics

Data Types

double | single

Direct Feedthrough

no

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

no

Algorithms

The Block LMS adaptive filter algorithm is defined by the following equations.

n=kN+iy(n)=wT(k1)u(n)e(n)=d(n)y(n)w(k)=w(k1)+f(u(n),e(n),μ)

The weight update function for the Block LMS adaptive filter algorithm is defined as

f(u(n),e(n),μ)=μi=0N1u(kN+i)e(kN+i)

The variables are as follows:

VariableDescription

n

The current time index

i

The iteration variable in each block, 0iN1

k

The block number

N

The block size

u(n)

The vector of buffered input samples at step n

w(n)

The vector of filter-tap estimates at step n

y(n)

The filtered output at step n

e(n)

The estimation error at time n

d(n)

The desired response at time n

µ

The adaptation step size

References

[1] Hayes, M. H. Statistical Digital Signal Processing and Modeling. New York: John Wiley & Sons, 1996.

Extended Capabilities

Version History

Introduced before R2006a