| Filter Design Toolbox | ![]() |
adaptlms Example -- System Identification
To use the adaptive filter functions in the toolbox you need to provide three things:
gremez is the unknown system.
adaptlms and initlms.
Start by defining an input signal x.
The input is broadband noise. For the unknown system filter, use gremez to create a twelfth-order lowpass filter:
Although you do not need them here, include the err and res output arguments.
Now filter the signal through the unknown system to get the desired signal.
With the unknown filter designed and the desired signal in place you can apply the adaptive LMS filter to identify the unknown.
Preparing the adaptive filter algorithm requires that you provide starting values for estimates of the filter coefficients and the LMS step size in a single structure s. We use initlms to populate the structure. You could start with estimated coefficients of some set of nonzero values; this example uses zeros for the 12 initial filter weights. For the step size, 0.8 is a reasonable value -- a good compromise between being large enough to converge well within the 500 iterations (500 input sample points) and small enough to create an accurate copy of the unknown filter.
Structure s now comprises the following fields.
Finally, using the desired signal, d, the input to the filter, x, and the structure that contains the algorithm initialization settings, s, we run the adaptive filter to determine the unknown system and plot the results, comparing the actual coefficients from gremez to the coefficients found by adaptlms.
In the stem plot the actual and estimated filter weights are the same. 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 estimated weights fail to approximate the actual weights closely.
Since this may be because we did not iterate over the LMS algorithm enough times, try using 1000 samples. With 1000 samples, the stem plot, shown in the next figure, looks much better, albeit at the expense of much more computation. Clearly you should take care to select the step size with both the computation required and the fidelity of the estimated filter in mind.
| Examples of Adaptive Filters That Use LMS Algorithms | adaptnlms Example -- System Identification | ![]() |