Signal Toolkit - firpmord
- Function File:
[n, Fout, a, w] =
firpmord(f, a, d)
- Function File:
[n, Fout, a, w] =
firpmord(f, a, d, fs)
- Function File:
c =
firpmord(f, a, d, "cell")
- Function File:
c =
firpmord(f, a, d, fs, "cell")
-
Estimate the filter-order needed for
firpm
to design a type-I or type-II linear-phase FIR filter according to the given specifications.Arguments
- f
A vector of real-numbers, increasing in the range (0, fs/2), giving the frequencies of the left and right edges of each band for which a specific amplitude response is desired (omitting 0 and fs/2, which are implied): [r1 l2 r2 …]. Transition-bands are defined implicitly as the regions between the given bands.
- a
A vector of real-numbers giving the ideal amplitude response. An amplitude value is given for each band specified by f: [a1 a2 …]. 1 represents unity-gain, 0 represents infinite attenuation, and −1 represents a phase change of pi radians.
- d
A vector of positive real-numbers giving the maximum allowable linear deviation from the amplitudes given in a, thus constraining the actual amplitude response (where defined by f) to be within a +/− d. Note that, though related, d does not equate to
firpm
’s w argument.- fs
-
The sampling-frequency, which defaults to 2.
Usage
The function returns the estimated filter-order, together with the other design specification values, in one of two forms suitable for use with
firpm
. By default, multiple return values are used; alternatively, by giving"cell"
(or"c"
) as the last argument tofirpmord
, the returned values are contained within a cell-array that can, if desired, be passed directly tofirpm
.The following examples illustrate the use of both mechanisms, as well as aspects of
firpmord
usage in general:# Low-pass; frequencies in kHz: [n f a w] = firpmord ([2.5 3], [1 0], [0.01 db2mag(-60)], 8); b = firpm (n, f, a, w);
# Band-pass: c = firpmord ([3 4 8 9], [0 1 0], [1e-3 1e-2 1e-3], 20, "cell"); b = firpm (c{:});
# High-pass: b = firpm (firpmord ([6.4 8]/16, [0 1], [1e-4 0.01], "c"){:});
In cases where elements of d follow a repeating pattern (e.g. all the elements are equal, or elements corresponding to pass-bands are equal and elements corresponding to stop-bands are equal), only as many elements as are needed to establish the pattern need be given.
For example, the following
firpmord
invocation pairs are equivalent:# Low-pass: firpmord ([0.4 0.5], [0 1], [db2mag(-72) db2mag(-72)]); firpmord ([0.4 0.5], [0 1], [db2mag(-72)]);
# Multi-band-pass: ds = db2mag(-80); dp = 0.01; firpmord ([1 2 3 4 5 6 7 8]/10, [0 1 0 1 0], [ds dp ds dp ds]); firpmord ([1 2 3 4 5 6 7 8]/10, [0 1 0 1 0], [ds dp]);
Notes
The estimation algorithm used is per Ichige et al.1 Accuracy tends to decrease as the number of bands increases. Even with two bands (i.e. high-pass or low-pass), the algorithm may under- or over-estimate. See the
firpmord
demonstrations for some examples.In order to precisely determine the minimum order needed for a particular design,
firpmord
could be used to seed an algorithm iterating invocations offirpm
(as exemplified in demonstration number five).Related documentation
See also: firpm, kaiserord.