Engee documentation

firls

Page in progress.

Calculation of the coefficients of a linear phase response FIR filter using the least squares method.

Library

EngeeDSP

Syntax

Function call

  • b = firls(n,f,a) — returns a vector string b, containing n+1 coefficients of the FIR filter of the order n. The frequency and amplitude characteristics of the resulting filter correspond to the characteristics of the vectors f and a.

  • b = firls(n,f,a,w) — uses an argument w for weighing frequency intervals.

  • b = firls(___,ftype) — designs antisymmetric (odd) filters, where the argument ftype defines a filter as a differentiator or a Hilbert transform.

Arguments

Input arguments

# n — filter order

+ real positive scalar

Details

The filter order is set as a real positive number.

# f — normalized frequency values

+ real-valued vector

Details

Normalized frequency values, set as a vector of real numbers. The argument must be in the range [0,1], where 1 corresponds to the Nyquist frequency. The number of elements of a vector is always a multiple 2. The frequencies should be arranged in non-decreasing order.

# a — required amplitude

+ vector

Details

Required amplitudes at the points specified in f, are specified as a vector. Length f and a it must be the same. The length must be an even number.

  • Required amplitude at frequencies between pairs of points for odd numbers — this is a straight line segment connecting the points and .

  • Required amplitude at frequencies between pairs of points with an even number not defined. The areas between such points are transition areas or areas that are not relevant for a particular application.

# w — weights

+ real-valued vector

Details

The weights used to adjust the approximation in each frequency band are given as a vector of real numbers. Length of the argument w It is half the length f and a therefore, there is exactly one weight for each strip.

# ftype — filter type

+ "hilbert" | "differentiator"

Details

The filter type for linear phase characteristic filters with odd symmetry (type III and type IV), defined as "hilbert" or "differentiator":

  • "hilbert" — output coefficients in b they obey the ratio , . This class of filters includes the Hilbert converter, whose specified amplitude is 1 in the entire bandwidth.

  • "differentiator" — for bands with non-zero amplitude, the filter weighs the error by a factor of , so the error at low frequencies is significantly less than at high frequencies. For FIR differentiators, the amplitude characteristic of which is proportional to the frequency, these filters minimize the maximum relative error (the maximum value of the ratio of error to a given amplitude).

Output arguments

# b — filter coefficients

+ vector string

Details

Filter coefficients returned as a vector string of length n+1. The coefficients are arranged in ascending order.

Algorithms

Function firls designs a FIR filter with a linear phase response that minimizes the weighted integral square error between the ideal piecewise linear function and the amplitude-frequency response of the filter in a given frequency range.

The book [2] describes the theoretical approach underlying the function firls. The function solves a system of linear equations using the operator \in Engee. For the order filter the solution of the system of equations involves a square matrix of the scalar product of the size , where When odd, and When even number.

Input arguments and the frequency-amplitude characteristics of the filter are set:

  • — a vector of pairs of frequency values set in the range from 0 before 1, where 1 corresponds to the Nyquist frequency. The frequencies should be arranged in ascending order. You can specify duplicate frequency values.

  • — a vector containing the required amplitudes at the points specified in the vector .

    Required amplitude function at frequencies between pairs of points for odd numbers — this is a straight line segment connecting the points and .

    Required amplitude function at frequencies between pairs of points with an even number not defined. These are transitional ("unimportant") areas.

  • and they have the same length. This length must be an even number.

Function firls designs filters with linear phase characteristics of type I, II, III and IV. Filters of type I and II are used by default for even and odd numbers. accordingly, while the flags "hilbert" and "differentiator" create type III filters ( even) and IV ( odd). Different types of filters have different symmetries and limitations on frequency characteristics (for more information, see [1]).

Filter type with linear phase response Filter order Symmetry of coefficients Response H(f), f = 0 Response H(f), f = 1 (Nyquist)

Type I

Even-numbered

There are no restrictions

There are no restrictions

Type II

Odd

There are no restrictions

Type III

Even-numbered

Type IV

Odd

There are no restrictions

Literature

  1. Oppenheim, Alan V., and Ronald W. Schafer, with John R. Buck. Discrete-Time Signal Processing. Upper Saddle River, NJ: Prentice Hall, 1999.

  2. Parks, Thomas W., and C. Sidney Burrus. Digital Filter Design. Hoboken, NJ: John Wiley & Sons, 1987, pp. 54–83.