Normalized least mean squares adaptive filter
adaptfilt.nlms
will be removed in a future
release. Use dsp.LMSFilter
instead.
ha = adaptfilt.nlms(l,step,leakage,offset,coeffs,states)
ha = adaptfilt.nlms(l,step,leakage,offset,coeffs,states)
constructs
a normalized leastmean squares (NLMS) FIR adaptive filter object
named ha
.
For information on how to run data through your adaptive filter
object, see the Adaptive Filter Syntaxes section of the reference
page for filter
.
Entries in the following table describe the input arguments
for adaptfilt.nlms
.
Input Argument  Description 

 Adaptive filter length (the number of coefficients or
taps) and it must be a positive integer. 
 NLMS step size. It must be a scalar between 0 and 2.
Setting this step size value to one provides the fastest convergence. 
 NLMS leakage factor. It must be a scalar between zero
and one. When it is less than one, a leaky NLMS algorithm results. 
 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 dividebynearzero
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, 
 Vector composed of your initial filter coefficients.
Enter a length 
 Your initial adaptive filter states appear in the 
In the syntax for creating the adaptfilt
object,
the input options are properties of the object you create. This table
lists the properties for normalized LMS objects, their default values,
and a brief description of the property.
Property  Range  Property Description 

 None  Reports the adaptive filter algorithm the object uses during adaptation 
 Vector of elements  Vector containing the initial filter coefficients. It
must be a length 
 Any positive integer  Reports the length of the filter, the number of coefficients or taps 
 0 to 1  NLMS leakage factor. It must be a scalar between zero
and one. When it is less than one, a leaky NLMS algorithm results. 
 0 or greater  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 dividebynearzero
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, 

 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. 
 Vector of elements, data type double  Vector of the adaptive filter states. 
 0 to 1  NLMS step size. It must be a scalar between zero and
one. Setting this step size value to one provides the fastest convergence. 
To help you compare this algorithm's performance to other LMSbased 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]); legend('Desired','Output','Error'); title('System Identification of FIR Filter'); xlabel('Time Index'); ylabel('Signal Value'); subplot(2,1,2); stem([b', ha.coefficients']); legend('Actual','Estimated'); grid on; xlabel('Coefficient #'); ylabel('Coefficient Value');
As you see from the figure, the nlms
variant
again closely matches the actual filter coefficients in the unknown
FIR filter.
adaptfilt.ap
 adaptfilt.apru
 adaptfilt.lms
 adaptfilt.rls
 adaptfilt.swrls