Anexo B AdaptFilt LMS Matlab

download Anexo B AdaptFilt LMS Matlab

of 2

Transcript of Anexo B AdaptFilt LMS Matlab

  • 8/10/2019 Anexo B AdaptFilt LMS Matlab

    1/2

    adaptfilt.lms

    FIR adaptive filter that uses LMS

    Syntaxha = adaptfilt.lms(l,step,leakage,coeffs,states)

    Description

    ha = adaptfilt.lms(l,step,leakage,coeffs,states)constructs an FIR LMS adaptive filter object ha.

    For information on how to run data through your adaptive filter object, see the Adaptive Filter Syntaxes section of the reference

    page forfilter.

    Input Arguments

    Entries in the following table describe the input arguments for adaptfilt.lms.

    Input

    Argument Description

    l Adaptive filter length (the number of coefficients or taps) and it must be a positive integer. ldefaults to 10.

    step LMS step size. It must be a nonnegative scalar. You can usemaxstepto determine a reasonable range of

    step size values for the signals being processed. stepdefaults to 0.1.

    leakage Your LMS leakage factor. It must be a scalar between 0 and 1. When leakageis less than

    one,adaptfilt.lmsimplements a leaky LMS algorithm. When you omit theleakageproperty in

    the calling syntax, it defaults to 1 providing no leakage in the adapting algorithm.

    coeffs Vector of initial filter coefficients. it must be a lengthlvector. coeffsdefaults to lengthlvector with

    elements equal to zero.

    states Vector of initial filter states for the adaptive filter. It must be a length l-1 vector. statesdefaults to a length

    l-1 vector of zeros.

    Properties

    In the syntax for creating the adaptfiltobject, the input options are properties of the object created. This table lists the

    properties for the adaptfilt.lmsobject, 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

    Coefficients Vector of elements Vector containing the initial filter coefficients. It must be a

    lengthlvector where lis the number of filter

    coefficients. coeffsdefaults to a length lvector of zeros when you

    do not provide the vector as an input argument.

    FilterLength Any positive integer Reports the length of the filter, the number of coefficients or taps

    Leakage 0 to 1 LMS leakage factor. It must be a scalar between zero and one. When it is

    less than one, a leaky NLMS algorithm results. leakagedefaults to 1

    (no leakage).

    PersistentMemory falseor true 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.PersistentMemoryreturns to zero any property value that

    the filter changes during processing. Property values that the filter does

    not change are not affected. Defaults tofalse.

    States Vector of elements,

    data type double

    Vector of the adaptive filter states. statesdefaults to a vector of

    zeros which has length equal to (l- 1).

    http://www.mathworks.com/help/dsp/ref/filter.htmlhttp://www.mathworks.com/help/dsp/ref/filter.htmlhttp://www.mathworks.com/help/dsp/ref/filter.htmlhttp://www.mathworks.com/help/dsp/ref/maxstep.htmlhttp://www.mathworks.com/help/dsp/ref/maxstep.htmlhttp://www.mathworks.com/help/dsp/ref/maxstep.htmlhttp://www.mathworks.com/help/dsp/ref/maxstep.htmlhttp://www.mathworks.com/help/dsp/ref/filter.html
  • 8/10/2019 Anexo B AdaptFilt LMS Matlab

    2/2

    Property Range Property Description

    StepSize 0 to 1 LMS step size. It must be a scalar between zero and one. Setting this step

    size value to one provides the fastest convergence. stepdefaults to 0.1.

    Examples

    Use 500 iterations of an adapting filter system to identify and unknown 32nd-order FIR filter.

    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 = 0.008; % LMS step size.

    ha = adaptfilt.lms(32,mu);

    [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;

    Using LMS filters in an adaptive filter architecture is a time honored means for identifying an unknown filter. By running the

    example code provided you can demonstrate one process to identify an unknown FIR filter.

    References

    Shynk J.J., "Frequency-Domain and Multirate Adaptive Filtering," IEEESignal Processing Magazine, vol. 9, no. 1, pp. 14-37,

    Jan. 1992.