Accelerating the pace of engineering and science

# dsp.LMSFilter System object

Package: dsp

## Description

The LMSFilter implements an adaptive FIR filter object that returns the filtered output, the error vector, and filter weights. The LMS filter uses one of five different LMS algorithms.

To implement the adaptive FIR filter object:

1. Define and set up your adaptive FIR filter object. See Construction.

2. Call step to implement the filter according to the properties of dsp.LMSFilter. The behavior of step is specific to each object in the toolbox.

## Construction

H = dsp.LMSFilter returns an adaptive FIR filter object, H, that computes the filtered output, filter error and the filter weights for a given input and desired signal using the Least Mean Squares (LMS) algorithm.

H = dsp.LMSFilter('PropertyName', PropertyValue,...) returns an LMS filter object, H, with each property set to the specified value.

H = dsp.LMSFilter(LEN,'PropertyName',PropertyValue,...) returns an LMS filter object, H, with the Length property set to LEN, and other specified properties set to the specified values.

## Methods

 clone Create LMS filter object with same property values getNumInputs Number of expected inputs to step method getNumOutputs Number of outputs of step method isLocked Locked status for input attributes and nontunable properties maxstep Maximum step size for LMS adaptive filter convergence msepred Predicted mean-square error for LMS filter msesim Mean-squared error for LMS filter release Allow property value and input characteristics changes reset Reset filter states for LMS filter step Apply LMS adaptive filter to input

## Examples

expand all

### System Identification Using LMS Filter

```hlms1 = dsp.LMSFilter(11,'StepSize',0.01);
hfilt = dsp.FIRFilter; % System to be identified
hfilt.Numerator = fir1(10,.25);
x = randn(1000,1); % input signal

d = step(hfilt, x) + 0.01*randn(1000,1); % desired signal
[y,e,w] = step(hlms1,x,d);

subplot(2,1,1);
plot(1:1000, [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([hfilt.Numerator.',w]);
legend('Actual','Estimated');
xlabel('coefficient #');
ylabel('coefficient value');
```

### Cancel Noise Using LMS Filter

```hlms2 = dsp.LMSFilter('Length',11, ...
'Method','Normalized LMS',...
'StepSizeSource','Input port', ...
'WeightsOutputPort',false);
hfilt2 = dsp.FIRFilter('Numerator', fir1(10,[.5, .75]));
x = randn(1000,1); % Noise
d = step(hfilt2,x) + sin(0:.05:49.95)'; % Noise + Signal
a = 1; % adaptation control
mu = 0.05; % step size
[y, err] = step(hlms2,x,d,mu,a);

subplot(2,1,1);
plot(d);
title('Noise + Signal');
subplot(2,1,2);
plot(err);
title('Signal');
```

## Algorithms

This filter's algorithm is defined by the following equations.

$\begin{array}{c}y\left(n\right)={w}^{T}\left(n-1\right)u\left(n\right)\\ e\left(n\right)=d\left(n\right)-y\left(n\right)\\ w\left(n\right)=\alpha w\left(n-1\right)+f\left(u\left(n\right),e\left(n\right),\mu \right)\end{array}$

The various LMS adaptive filter algorithms available in this System object™ are defined as:

• LMS:

$f\left(u\left(n\right),e\left(n\right),\mu \right)=\mu e\left(n\right){u}^{*}\left(n\right)$

• Normalized LMS:

$f\left(u\left(n\right),e\left(n\right),\mu \right)=\mu e\left(n\right)\frac{{u}^{\ast }\left(n\right)}{\epsilon +{u}^{H}\left(n\right)u\left(n\right)}$

• Sign-Error LMS:

$f\left(u\left(n\right),e\left(n\right),\mu \right)=\mu sign\left(e\left(n\right)\right)u*\left(n\right)$

• Sign-Data LMS:

$f\left(u\left(n\right),e\left(n\right),\mu \right)=\mu e\left(n\right)sign\left(u\left(n\right)\right)$

where u(n) is real.

• Sign-Sign LMS:

$f\left(u\left(n\right),e\left(n\right),\mu \right)=\mu sign\left(e\left(n\right)\right)sign\left(u\left(n\right)\right)$

where u(n) is real.

The variables are as follows:

VariableDescription

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

µ