firpmord - Parks-McClellan optimal FIR filter order estimation

Syntax

[n,fo,ao,w] = firpmord(f,a,dev)
[n,fo,ao,w] = firpmord(f,a,dev,fs)
c = firpmord(f,a,dev,fs,'cell')

Description

[n,fo,ao,w] = firpmord(f,a,dev) finds the approximate order, normalized frequency band edges, frequency band amplitudes, and weights that meet input specifications f, a, and dev.

Use firpm with the resulting order n, frequency vector fo, amplitude response vector ao, and weights w to design the filter b which approximately meets the specifications given by firpmord input parameters f, a, and dev.

b = firpm(n,fo,ao,w)

[n,fo,ao,w] = firpmord(f,a,dev,fs) specifies a sampling frequency fs. fs defaults to 2 Hz, implying a Nyquist frequency of 1 Hz. You can therefore specify band edges scaled to a particular application's sampling frequency.

In some cases firpmord underestimates the order n. If the filter does not meet the specifications, try a higher order such as n+1 or n+2.

c = firpmord(f,a,dev,fs,'cell') generates a cell-array whose elements are the parameters to firpm.

Examples

Example 1

Design a minimum-order lowpass filter with a 500 Hz passband cutoff frequency and 600 Hz stopband cutoff frequency, with a sampling frequency of 2000 Hz, at least 40 dB attenuation in the stopband, and less than 3 dB of ripple in the passband:

rp = 3;           % Passband ripple
rs = 40;          % Stopband ripple
fs = 2000;        % Sampling frequency
f = [500 600];    % Cutoff frequencies
a = [1 0];        % Desired amplitudes
% Compute deviations
dev = [(10^(rp/20)-1)/(10^(rp/20)+1)  10^(-rs/20)]; 
[n,fo,ao,w] = firpmord(f,a,dev,fs);
b = firpm(n,fo,ao,w);
freqz(b,1,1024,fs);
title('Lowpass Filter Designed to Specifications');

Note that the filter falls slightly short of meeting the stopband attenuation and passband ripple specifications. Using n+1 in the call to firpm instead of n achieves the desired amplitude characteristics.

Example 2

Design a lowpass filter with a 1500 Hz passband cutoff frequency and 2000 Hz stopband cutoff frequency, with a sampling frequency of 8000 Hz, a maximum stopband amplitude of 0.1, and a maximum passband error (ripple) of 0.01:

[n,fo,ao,w] = firpmord([1500 2000],[1 0],[0.01 0.1],8000 );
b = firpm(n,fo,ao,w);

This is equivalent to

c = firpmord( [1500 2000],[1 0],[0.01 0.1],8000,'cell');
b = firpm(c{:});

Algorithm

firpmord uses the algorithm suggested in [1]. This method is inaccurate for band edges close to either 0 or the Nyquist frequency (fs/2).

References

[1] Rabiner, L.R., and O. Herrmann, "The Predictability of Certain Optimum Finite Impulse Response Digital Filters," IEEE® Trans. on Circuit Theory, Vol. CT-20, No. 4 (July 1973), pp.401-408.

[2] Rabiner, L.R., and B. Gold. Theory and Application of Digital Signal Processing. Englewood Cliffs, NJ: Prentice-Hall, 1975, pp.156-157.

See Also

buttord, cheb1ord, cheb2ord, ellipord, kaiserord, firpm

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS