Engee documentation

firpmord

Estimation of the optimal FIR filter order by the Parks-McClellan method.

Library

EngeeDSP

Syntax

Function call

  • n, fo, ao, w = firpmord(f, a, dev) — returns the approximate order n, normalized frequency band boundaries fo, frequency band amplitudes ao and the weighting factors w which correspond to the input arguments f, a, dev.

  • _ = firpmord(_, fs) — the sampling rate is also set fs. Meaning fs the default value is 2 Hz, which corresponds to the Nyquist frequency 1 Hz. You can specify band boundaries that are scaled according to the sampling rate of a particular application. This syntax can be used with any of the previous input options.

  • c = firpmord(_, "cell") — returns an array of cells c, the elements of which are the parameters of the function firpm.

Arguments

Input arguments

# f — the boundaries of the frequency range

+ vector of real numbers

Details

The boundaries of the frequency range, defined as a vector of real numbers. The argument must be in the range , where — Nyquist frequency. The number of elements of a vector is always a multiple 2. The frequencies should be arranged in ascending order.

# a — required amplitude values

+ vector

Details

Required values of the amplitudes at the points contained in f, set as a vector. Vectors f and a must satisfy the condition length(f)=2lenth(a)-2. The desired function is piecewise constant.

# dev — maximum allowable deviation

+ vector

Details

The maximum allowable deviation, set as a vector. Vector dev has the same size as a. It determines the maximum allowable deviation or ripple between the frequency response and the required output filter amplitude for each band.

# fs — sampling rate
2 Hz (by default) | real scalar

Details

The sampling rate, set as a real scalar.

Output arguments

# n — filter order

+ positive integer

Details

The filter order returned as a positive integer.

# fo — normalized frequency values

+ vector of real numbers

Details

Normalized frequency values returned 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 ascending order.

# ao — amplitude response

+ vector of real numbers

Details

The amplitude characteristic returned as a vector of real numbers.

# w — weight coefficients

+ vector of real numbers

Details

The weighting coefficients used to adjust the approximation in each frequency band, returned as a vector of real numbers. Vector length w It is half the length f and a therefore, there is exactly one weighting factor value for each band.

# c — FIR filter parameters

+ array of cells

Details

FIR filter parameters returned as an array of cells.

Algorithms

Function firpmord uses the algorithm proposed in [1]. This function gives inaccurate results for band boundary values close to either 0, or to the Nyquist frequency, fs/2.

In some cases firpmord underestimates or overestimates the order n. If the filter does not meet the requirements, try a higher order, for example, n+1 or n+2.

Literature

  1. Rabiner, Lawrence R., and Otto Herrmann. “The Predictability of Certain Optimum Finite-Impulse-Response Digital Filters.” IEEE® Transactions on Circuit Theory. Vol. 20, Number 4, 1973, pp. 401–408.

  2. Rabiner, Lawrence R., and Bernard Gold. Theory and Application of Digital Signal Processing. Englewood Cliffs, NJ: Prentice-Hall, 1975, pp. 156–157.