System identification is the process of identifying the coefficients of an unknown system using an adaptive filter. The general layout of the process is shown in System Identification –– Using an Adaptive Filter to Identify an Unknown System. The main components involved are:

The adaptive filter algorithm. In this example, set the

`Method`

property of`dsp.LMSFilter`

to`'LMS'`

, to choose the LMS adaptive filter algorithm.An unknown system or process to adapt to. In this example, the filter designed by

`fircband`

is the unknown system.Appropriate input data to exercise the adaptation process. In terms of the generic LMS model, these are the desired signal $\mathit{d}\left(\mathit{k}\right)$ and the input signal $\mathit{x}\left(\mathit{k}\right)$.

The objective of the adaptive filter is to minimize the error signal between the output of the adaptive filter, $\mathit{y}\left(\mathit{k}\right)$, and the output of the unknown system (or the system to be identified), $\mathit{d}\left(\mathit{k}\right)$. Once the error signal is minimal, the adapted filter resembles the unknown system. The coefficients of both the filters match closely.

**Note**: If you are using R2016a or an earlier release, replace each call to the object with the equivalent step syntax. For example, `obj(x)`

becomes `step(obj,x)`

.

Create a `dsp.FIRFilter`

object that represents the system to be identified. Use the `fircband`

function to design the filter coefficients. The filter designed is a lowpass filter constrained to 0.2 ripple in the stopband.

filt = dsp.FIRFilter; filt.Numerator = fircband(12,[0 0.4 0.5 1], [1 1 0 0], [1 0.2],... {'w' 'c'});

Pass the signal, `x`

to the FIR filter. The desired signal, `d`

, is the sum of the output of the unknown system (FIR filter) and an additive noise signal, `n`

.

x = 0.1*randn(250,1); n = 0.01*randn(250,1); d = filt(x) + n;

With the unknown filter designed and the desired signal in place, construct and apply the adaptive LMS filter object to identify the unknown filter.

Preparing the adaptive filter object requires that you provide starting values for estimates of the filter coefficients and the LMS step size (`mu`

). You could start with estimated coefficients of some set of nonzero values. This example uses zeros for the 12 initial filter weights. Set the `InitialConditions`

property of `dsp.LMSFilter`

to the desired initial values of the filter weights. For the step size, 0.8 is a good compromise between being large enough to converge well within the 250 iterations (250 input sample points) and small enough to create an accurate estimate of the unknown filter.

Create a `dsp.LMSFilter`

object to create an adaptive filter that uses the LMS adaptive algorithm. Set the length of the adaptive filter to 13 taps and the step size to 0.8.

```
mu = 0.8;
lms = dsp.LMSFilter(13,'StepSize',mu)
```

lms = dsp.LMSFilter with properties: Method: 'LMS' Length: 13 StepSizeSource: 'Property' StepSize: 0.8000 LeakageFactor: 1 InitialConditions: 0 AdaptInputPort: false WeightsResetInputPort: false WeightsOutput: 'Last' Show all properties

Pass the primary input signal, `x`

, and the desired signal, `d`

, to the LMS filter. Run the adaptive filter to determine the unknown system. The output, `y`

, of the adaptive filter is the signal converged to the desired signal, `d`

*, *thereby minimizing the error, `e`

, between the two signals.

Plot the results. The output signal does not match the desired signal as expected, making the error between the two non-trivial.

[y,e,w] = lms(x,d); plot(1:250, [d,y,e]) title('System Identification of an FIR filter') legend('Desired','Output','Error') xlabel('Time index') ylabel('Signal value')

The weights vector, `w`

, represents the coefficients of the LMS filter that is adapted to resemble the unknown system (FIR filter). To confirm the convergence, compare the numerator of the FIR filter and the estimated weights of the adaptive filter.

The estimated filter weights do not closely match the actual filter weights, confirming the results seen in the previous signal plot.

stem([(filt.Numerator).' w]) title('System Identification by Adaptive LMS Algorithm') legend('Actual Filter Weights','Estimated Filter Weights',... 'Location','NorthEast')

As an experiment, try changing the step size to `0.2`

. Repeating the example with `mu = 0.2`

results in the following stem plot. The filters have not converged and estimated weights fail to approximate the actual weights closely.

mu = 0.2; lms = dsp.LMSFilter(13,'StepSize',mu); [~,~,w] = lms(x,d); stem([(filt.Numerator).' w]) title('System Identification by Adaptive LMS Algorithm') legend('Actual Filter Weights','Estimated Filter Weights',... 'Location','NorthEast')

Increase the frame size of the desired signal. Even though this increases the computation involved, the LMS algorithm now has more data that can be used for adaptation. With 1000 samples of signal data and a step size of 0.2, the coefficients are aligned closer than before, indicating an improved convergence.

release(filt); x = 0.1*randn(1000,1); n = 0.01*randn(1000,1); d = filt(x) + n; [y,e,w] = lms(x,d); stem([(filt.Numerator).' w]) title('System Identification by Adaptive LMS Algorithm') legend('Actual Filter Weights','Estimated Filter Weights',... 'Location','NorthEast')

Further increase the number of data samples by inputing the data through iterations. Run the algorithm on 4000 samples of data, passed to the LMS algorithm in batches of 1000 samples, over 4 iterations.

Compare the filter weights. The weights of the LMS filter match very closely to the weights of the FIR filter indicating a good convergence.

release(filt); n = 0.01*randn(1000,1); for index = 1:4 x = 0.1*randn(1000,1); d = filt(x) + n; [y,e,w] = lms(x,d); end stem([(filt.Numerator).' w]) title('System Identification by Adaptive LMS Algorithm') legend('Actual Filter Weights','Estimated Filter Weights',... 'Location','NorthEast')

The output signal matches the desired signal very closely, making the error between the two very close to zero.

plot(1:1000, [d,y,e]) title('System Identification of an FIR filter') legend('Desired','Output','Error') xlabel('Time index') ylabel('Signal value')

- System Identification of FIR Filter Using Normalized LMS Algorithm
- Compare Convergence Performance between LMS Algorithm and Normalized LMS Algorithm

[1] Hayes, Monson H.,
*Statistical Digital Signal Processing and Modeling*, John
Wiley & Sons, 1996, 493–552.

[2] Haykin, Simon,
*Adaptive Filter Theory*, Prentice-Hall, Inc.,
1996