help - filter (filter design toolbox)

Upload: ipul

Post on 30-May-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/14/2019 Help - Filter (Filter Design Toolbox)

    1/7

    Filter Design Toolbox

    filter

    Apply filter objects to data and access states and filtering information

    Syntax

    Fixed-Point Filter Syntaxes

    y = filter(hd,x)

    y = filter(hd,x,dim)

    Adaptive Filter Syntax

    y = filter(ha,x,d)

    [y,e] = filter(ha,x,d)

    Multirate Filter Syntax

    y = filter(hm,x)

    y = filter(hm,x,dim)

    Description

    This reference page contains three sections that describe the syntaxes for the filter objects:

    Fixed-Point Filter Syntaxes

    Adaptive Filter Syntaxes

    Multirate Filter Syntaxes

    Fixed-Point Filter Syntaxes

    y = filter(hd,x) filters a vector of real or complex input datax through a fixed-point

    filterhd, producing filtered output datay. The vectors x and y have the same length. filter

    stores the final conditions for the filter in the States property ofhd--hd.states.

    When you set the property PersistentMemory to false (the default setting), the initial

    conditions for the filter are set to zero before filtering starts. To use nonzero initial conditions

    forhd, set PersistentMemory to true. Then set hd.states to a vector of

    nstates(hd) elements, one element for each state to set. If you specify a scalar for

    hd.states, filter expands the scalar to a vector of the proper length for the states. All

    elements of the expanded vector have the value of the scalar.

    Ifx is a matrix, y = filter(hd,x) filters along each column ofx to produce a matrix y of

    independent channels. Ifx is a multidimensional array, y = filter(hd,x) filters x along the

    first nonsingleton dimension ofx.

    To use nonzero initial conditions when you are filtering a matrix x, set the filter states to a

  • 8/14/2019 Help - Filter (Filter Design Toolbox)

    2/7

    matrix of initial condition values. Set the initial conditions by setting the States property for

    the filter (hd.states) to a matrix ofnstates(hd) rows and size(x,2) columns.

    y = filter(hd,x,dim) applies the filterhd to the input data located along the specific

    dimension ofx specified by dim.

    When you are filtering multichannel data,dim lets you specify which dimension of the input

    matrix to filter along--whether a row represents a channel or a column represents a channel.

    When you provide thedim input argument, the filter operates along the dimension specified

    by dim. When your input data x is a vector or matrix and dim is 1, each column ofx is

    treated as a one input channel. When dim is 2, the filter treats each row of the input x as a

    channel.

    To filter multichannel data in a loop environment, you must use thedim input argument to

    set the proper processing dimension.

    You specify the initial conditions for each channel individually, when needed, by setting

    hm.states to a matrix ofnstates(hd) rows (one row containing the states for one

    channel of input data) andsize(x,2) columns (one column containing the filter states foreach channel).

    Adaptive Filter Syntaxes

    y = filter(ha,x,d) filters a vector of real or complex input datax through an adaptive

    filter object ha, producing the estimated desired response data y from the process of

    adapting the filter. The vectorsx and y have the same length. Use d for the desired signal.

    Note that d and x must be the same length signal chains.

    [y,e] = filter(ha,x,d) produces the estimated desired response data y and the

    prediction errore (refer to previous syntax for more information).

    Multirate Filter Syntaxes

    y = filter(hd,x) filters a vector of real or complex input datax through a fixed-point

    filterhd, producing filtered output datay. The vectors x and y have the same length. filter

    stores the final conditions for the filter in the States property ofhd--hd.states.

    y = filter(hm,x,dim) applies the filterhd to the input data located along the specific

    dimension ofx specified by dim.

    When you are filtering multichannel data,dim lets you specify which dimension of the input

    matrix to filter along--whether a row represents a channel or a column represents a channel.

    When you provide thedim input argument, the filter operates along the dimension specified

    by dim. When your input data x is a vector or matrix and dim is 1, each column ofx is

    treated as a one input channel. When dim is 2, the filter treats each row of the input x as achannel.

    To filter multichannel data in a loop environment, you must use thedim input argument to

    set the processing dimension.

    You specify the initial conditions for each channel individually, when needed, by setting

    hm.states to a matrix ofnstates(hm) rows (one row containing the states for one

  • 8/14/2019 Help - Filter (Filter Design Toolbox)

    3/7

    channel of input data) andsize(x,2) columns (one column containing the filter states for

    each channel).

    The number of data samples in your input data setx does not need to be a multiple of the

    rate change factorr for the object. When the rate change factor is not an even divisor of thenumber of input samplesx, filter processes the samples as shown in the following

    figure, where the rate change factor is 3 and the number of input samples is 23. Decimators

    always take the first input sample to generate the first output sample. After that, the next

    output sample comes after eachr number of input samples.

    Examples

    Filter a signal using a filter with various initial conditions (IC) or no initial conditions.

    % Do not set specific initial conditions.

    Now use nonzero initial conditions by setting ICs after before you filter.

    stem([y1 y2]) % Different sequences at the beginning.

    Looking at the stem plot shows that the sequences are different at the beginning of the filterprocess.

  • 8/14/2019 Help - Filter (Filter Design Toolbox)

    4/7

    Here is one way to use filter with streaming data.

    As an experiment, repeat the process, filtering the data as sections, rather than in

    streaming form.

    yloop = zeros(100,1) % Preallocate output array.

    for i=1:5,

    end

    Use a stem plot to see the comparison between streaming and block-by-block filtering.

  • 8/14/2019 Help - Filter (Filter Design Toolbox)

    5/7

    Filtering the signal section-by-section is equivalent to filtering the entire signal at once.

    To show the similarity between filtering with discrete-time and with multirate filters, this

    example demonstrates multirate filtering.

    First, filter without setting initial conditions.

    This time, set nonzero initial conditions before filtering the data.

  • 8/14/2019 Help - Filter (Filter Design Toolbox)

    6/7

    stem([y1(1:60) y2(1:60)]) % Show the filtering results.

    Note the different sequences at the start of filtering.

    Finally, try filtering streaming data.

    As with the discrete-time filter, filtering the signal section by section is equivalent to filtering

    the entire signal at once.

    yloop = zeros(100,1) % Preallocate output array.

    for i=1:5,

    end

    Algorithm

    Quantized Filters

    Thefilter command implements fixed- or floating-point arithmetic on the quantized filter

    structure you specify.

    The algorithm applied byfilter when you use a discrete-time filter object on an input

    signal depends on the response you chose for the filter, such as lowpass or Nyquist or

    bandstop. To learn more about each filter algorithm, refer to the literature reference provided

    on the appropriate discrete-time filter reference page.

    Note dfilt/filter does not normalize the filter coefficients automatically.

    Function filter supplied by MATLAB does normalize the coefficients.

    Adaptive Filters

    The algorithm used byfilter when you apply an adaptive filter object to a signal depends

    on the algorithm you chose for your adaptive filter. To learn more about each adaptive filter

    algorithm, refer to the literature reference provided on the appropriate

    adaptfilt.algorithm reference page.

    Multirate Filters

    The algorithm applied byfilter when you apply a multirate filter objects to signalsdepends on the algorithm you chose for the filter--the form of the multirate filter, such as

    decimator or interpolator. To learn more about each filter algorithm, refer to the literature

    reference provided on the appropriate multirate filter reference page.

    See Also

  • 8/14/2019 Help - Filter (Filter Design Toolbox)

    7/7

    adaptfilt, impz, mfilt, nstates

    dfilt in the Signal Processing Toolbox

    References[1] Oppenheim, A.V., and R.W. Schafer, Discrete-Time Signal Processing, Prentice-Hall,

    1989.

    filtmsb filtstates.cic

    1994-2005 The MathWorks, Inc. Terms of Use Patents Trademarks