DSP Blockset
  Go to block:
    Search    Help Desk 
Least Squares FIR Filter Design    Examples   See Also

Design and implement a least-squares FIR filter.

Library

Filter Designs, in Filtering

Description

The Least Squares FIR Filter Design block designs an FIR filter and applies it to the input using the Direct-Form II Transpose Filter block in the Filter Realizations library. The filter design uses the firls function in the Signal Processing Toolbox to minimize the integral of the squared error between the desired frequency response and the actual frequency response.

The Filter type parameter allows you to specify one of the following filters:

The Band-edge frequency vector parameter is a vector of frequency points in the range 0 to 1, where 1 corresponds to half the sampling frequency (the Nyquist frequency). This vector must have even length, and intermediate points must appear in ascending order. The Gains at these frequencies parameter is a vector containing the desired magnitude response at the corresponding points in the Band-edge frequency vector.

Each odd-indexed frequency-amplitude pair defines the left endpoint of a line segment representing the desired magnitude response in that frequency band. The corresponding even-indexed frequency-amplitude pair defines the right endpoint. Between the frequency bands specified by these end-points, there may be undefined sections of the specified frequency response. These are called "don't care" or "transition" regions, and the magnitude response in these areas is a result of the optimization in the other (specified) frequency ranges.

The Weights parameter is a vector that specifies the emphasis to be placed on minimizing the error in certain frequency bands relative to others. This vector specifies one weight per band, so it is half the length of the Band-edge frequency vector and Gains at these frequencies vectors.

In most cases, differentiators and Hilbert transformers have only a single band, so the weight is a scalar value that does not affect the final filter. However, the Weights parameter is useful when using the block to design an antisymmetric multiband filter, such as a Hilbert transformer with stopbands.

For more information on the Band-edge frequency vector, Gains at these frequencies, and Weights parameters, see the "Working with Filter Designs" section of Chapter 3. For more on the FIR filter algorithm, see the description of the firls function in the Signal Processing Toolbox User's Guide.

The Frame-based inputs parameter allows you to choose between sample-based and frame-based operation.

Sample-Based Operation

When the check box is not selected (default), the block assumes that the input is a 1-by-N sample vector or M-by-N sample matrix. Each of the N vector elements (or M*N matrix elements) is treated as an independent channel, and the block filters each channel over time.

Frame-Based Operation

When the Frame-based inputs check box is selected, the block assumes that the input is an M-by-N frame matrix. Each of the N frames in the matrix contains M sequential time samples from an independent signal. The Number of channels parameter specifies the number of independent channels (columns), N, in the matrix, and the block filters each channel independently over time. Frame-based operation provides substantial increases in throughput rates, at the expense of greater model latency.

In both sample-based and frame-based operation, the output is the same size as the input.

Dialog Box

Filter type
The filter type.
Filter order
The filter order.
Band-edge frequency vector
A vector of frequency points, in ascending order, in the range 0 to 1. The value 1 corresponds to the Nyquist frequency. This vector must have even length.
Gains at these frequencies
A vector of frequency-response amplitudes corresponding to the points in the Band-edge frequency vector. This vector must be the same length as the Band-edge frequency vector.
Weights
A vector containing one weight for each frequency band. This vector must be half the length of the Band-edge frequency vector and Gains at these frequencies vectors.
Frame-based inputs
Selects frame-based operation.
Number of channels
For frame-based operation, the number of columns (frames) in the input matrix.

Examples

Example 1: Multiband

Consider a lowpass filter with a transition band in the normalized frequency range 0.4 to 0.5, and 10 times more error minimization in the stopband than the passband. In this case,

Example 2: Differentiator

Assume the specifications for a differentiator filter require it to have order 21. The "ramp" response extends over the entire frequency range. In this case, specify:

For a type III (even order) filter, the differentiation band should stop short of the Nyquist frequency. For example, if the filter order is 20, you could specify the block parameters as follows:

Example 3: Hilbert Transformer

Assume the specifications for a Hilbert transformer filter require it to have order 21. The passband extends over approximately the entire frequency range. In this case, specify:

References

Oppenheim, A. V. and R. W. Schafer. Discrete-Time Signal Processing. Englewood Cliffs, NJ: Prentice Hall, 1989.

Proakis, J. and D. Manolakis. Digital Signal Processing. 3rd ed. Englewood Cliffs, NJ: Prentice-Hall, 1996.

See Also

Digital FIR Filter Design
Remez FIR Filter Design
Yule-Walker IIR Filter Design
firls (Signal Processing Toolbox)


[ Previous | Help Desk | Next ]