| Filter Design Toolbox |
 |
adaptfilt.nlms
Construct a normalized LMS FIR adaptive filter object
Syntax
ha = adaptfilt.nlms(l,step,leakage,offset,coeffs,states)
Description
ha = adaptfilt.nlms(l,step,leakage,offset,coeffs,states)
constructs a normalized least-mean squares (NLMS) FIR adaptive filter object named ha.
Input Arguments
Entries in the following table describe the input arguments for adaptfilt.nlms.
Input Argument
|
Description
|
l
|
Adaptive filter length (the number of coefficients or taps) and it must be a positive integer. l defaults to 10.
|
step
|
NLMS step size. It must be a scalar between 0 and 2. Setting this step size value to one provides the fastest convergence. step defaults to 1.
|
leakage
|
NLMS leakage factor. It must be a scalar between zero and one. When it is less than one, a leaky NLMS algorithm results. leakage defaults to 1 (no leakage).
|
offset
|
Specifies an optional offset for the denominator of the step size normalization term. You must specify offset to be a scalar greater than or equal to zero. Nonzero offsets can help avoid a divide-by-near-zero condition that causes errors. Use this to avoid dividing by zero (or by very small numbers) when the square of the input data norm becomes very small (when the input signal amplitude becomes very small). When you omit it, offset defaults to zero.
|
coeffs
|
Vector composed of your initial filter coefficients. Enter a length l vector. coeffs defaults to a vector of zeros with length equal to the filter order.
|
states
|
Your initial adaptive filter states appear in the states vector. It must be a vector of length l-1. states defaults to a length l-1 vector with zeros for all of the elements.
|
adaptfilt.nlms Object Properties
In the syntax for creating the adaptfilt object, the input options are properties of the object you create. This table list all the properties for normalized LMS objects, their default values, and a brief description of the property.
Property
|
Range
|
Property Description
|
Algorithm
|
None
|
Reports the adaptive filter algorithm the object uses during adaptation
|
FilterLength
|
Any positive integer
|
Reports the length of the filter, the number of coefficients or taps
|
Coefficients
|
Vector of elements
|
Vector containing the initial filter coefficients. It must be a length l vector where l is the number of filter coefficients. coeffs defaults to length l vector of zeros when you do not provide the argument for input.
|
States
|
Vector of elements, data type double
|
Vector of the adaptive filter states. states defaults to a vector of zeros which has length equal to (l - 1).
|
StepSize
|
|
NLMS step size. It must be a scalar between zero and one. Setting this step size value to one provides the fastest convergence. step defaults to one.
|
Leakage
|
|
NLMS leakage factor. It must be a scalar between zero and one. When it is less than one, a leaky NLMS algorithm results. leakage defaults to 1 (no leakage).
|
Offset
|
|
Specifies an optional offset for the denominator of the step size normalization term. You must specify offset to be a scalar greater than or equal to zero. Nonzero offsets can help avoid a divide-by-near-zero condition that causes errors. Use this to avoid dividing by zero (or by very small numbers) when the square of the input data norm becomes very small (when the input signal amplitude becomes very small). When you omit it, offset defaults to zero.
|
ResetBeforeFiltering
|
off or on
|
Determine whether the filter states and coefficients get restored to their starting values for each filtering operation. The starting values are the values in place when you create the filter. ResetBeforeFiltering returns to zero any property value that the filter changes during processing. Property values that the filter does not change are not affected. Defaults to 'on'.
|
NumSamplesProcessed
|
Any integer
|
Returns the number of samples processed during filtering. Defaults to zero.
|
Example
To help you compare this algorithm's performance to other LMS-based algorithms, such as BLMS or LMS, this example demonstrates the NLMS adaptive filter in use to identify the coefficients of an unknown FIR filter of order equal to 32--an example used in other adaptive filter examples.
x = randn(1,500); % Input to the filter
b = fir1(31,0.5); % FIR system to be identified
n = 0.1*randn(1,500); % Observation noise signal
d = filter(b,1,x)+n; % Desired signal
mu = 1; % NLMS step size
offset = 50; % NLMS offset
ha = adaptfilt.nlms(32,mu,1,offset);
[y,e] = filter(ha,x,d);
subplot(2,1,1); plot(1:500,[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([b.',ha.coefficients.']);
legend('Actual','Estimated');
xlabel('Coefficient #'); ylabel('Coefficient Value'); grid on;
See Also
adaptfilt.ap, adaptfilt.ap2, adaptfilt.lms, adaptfilt.rls, adaptfilt.swrls
| adaptfilt.lsl | | adaptfilt.pbfdaf |  |
Learn more about the latest releases of MathWorks products:
|