| Filter Design Toolbox | ![]() |
Use the Parks-McClellan technique to design digital FIR filters
Syntax
b = gremez(n,f,a,w) b = gremez(n,f,a,'hilbert') b = gremez(n,f,a,'differentiator') b = gremez(m,f,a,r) b = gremez({m,ni},f,a,r) b = gremez(n,f,a,w,c) b = gremez(n,f,a,w,e) b = gremez(n,f,a,s) b = gremez(n,f,a,s,w,e)
Description
gremez is a minimax filter design algorithm you use to design the following types of real FIR filters:
b = returns a length gremez(n,f,a,w)
n+1 linear phase FIR filter which has the best approximation to the desired frequency response described by f and a in the minimax sense. w is a vector of weights, one per band. When you omit w, all bands are weighted equally. For more information on the input arguments, refer to remez in Signal Processing Toolbox User's Guide.
b = and gremez(n,f,a,'hilbert')
b = gremez(n,f,a,'differentiator') design FIR Hilbert transformers and differentiators. For more information on designing these filters, refer to remez in Signal Processing Toolbox User's Guide.
b = where gremez(m,f,a,r),
m is one of 'minorder', 'mineven' or 'minodd', designs filters repeatedly until the minimum order filter, as specified in m, that meets the specifications is found. r is a vector containing the peak ripple per frequency band. You must specify r. When you specify 'mineven' or 'minodd', the minimum even or odd order filter is found.
b = where gremez({m,ni},f,a,r)
m is one of 'minorder', 'mineven' or 'minodd', uses ni as the initial estimate of the filter order. ni is optional for common filter designs, but it must be specified for designs in which remezord cannot be used, such as while designing differentiators or Hilbert transformers.
b = designs filters having constrained error magnitudes (ripples). gremez(n,f,a,w,c)
c is a cell array of strings of length w. The entries of c must be either 'c' to indicate that the corresponding element in w is a constraint (the ripple for that band cannot exceed w) or 'w' indicating that the corresponding entry in w is a weight. There must be at least one unconstrained band--c must contain at least one 'w' entry. For example,
uses a weight of one in the passband, and constrains the stopband ripple to 0.2 or less. b = gremez(12,[0 0.4 0.5 1], [1 1 0 0], [1 0.2], {'w' 'c'})
A hint about using constrained values: if the resulting filter does not touch the constraints, increase the error weighting you apply to the unconstrained bands.
b = specifies independent approximation errors for different bands. Use this syntax to design extra ripple or maximal ripple filters. These filters have interesting properties such as having the minimum transition width. gremez(n,f,a,w,e)
e is a cell array of strings specifying the approximation errors to use. Its length must equal the number of bands. Entries of e must be in the form 'e#' where # indicates which approximation error to use for the corresponding band. For example, when e = {'e1','e2','e1'}, the first and third bands use the same approximation error 'e1' and the second band uses a different one 'e2'. Note that when all bands use the same approximation error, such as {'e1','e1','e1',...}, it is equivalent to omitting e, as in b = gremez(n,f,a,w).
b = is used to design filters with special properties at certain frequency points. gremez(n,f,a,s)
s is a cell array of strings and must be the same length as f and a. Entries of s must be one of:
'n' - normal frequency point.
's' - single-point band. The frequency "band" is given by a single point. The corresponding gain at this frequency point must be specified in a.
'f' - forced frequency point. Forces the gain at the specified frequency band to be the value specified.
'i' - indeterminate frequency point. Use this argument when adjacent bands abut one another (no transition region).
For example, the following command designs a bandstop filter with zero-valued single-point stop bands (notches) at 0.25 and 0.55.
b = gremez(42,[0 0.2 0.25 0.3 0.5 0.55 0.6 1],[1 1 0 1 1 0 1 1],...
{'n' 'n' 's' 'n' 'n' 's' 'n' 'n'})
b = gremez(82,[0 0.055 0.06 0.1 0.15 1],[0 0 0 0 1 1],...
{'n' 'i' 'f' 'n' 'n' 'n'})
designs a highpass filter with the gain at 0.06 forced to be zero. The band edge at 0.055 is indeterminate since the first two bands actually touch. The other band edges are normal.
b = specifies weights and independent approximation errors for filters with special properties. The weights and properties are included in vectors gremez(n,f,a,s,w,e)
w and e. Sometimes, you may need to use independent approximation errors to get designs with forced values to converge. For example,
b = gremez(82,[0 0.055 0.06 0.1 0.15 1], [0 0 0 0 1 1],...
{'n' 'i' 'f' 'n' 'n' 'n'}, [10 1 1] ,{'e1' 'e2' 'e3'});
b = designs a type 1 filter (even-order symmetric). You can specify type 2 (odd-order symmetric), type 3 (even-order antisymmetric), and type 4 (odd-order antisymmetric) filters as well. Note that restrictions apply to gremez(...,'1')
a at f=0 or f=1 for FIR filter types 2, 3, and 4.
b = designs a minimum-phase FIR filter. You can use the argument gremez(...,'minphase')
'maxphase' to design a maximum phase FIR filter.
b = returns a warning when there are potential transition-region anomalies.gremez(..., 'check')
b = remez(...,{lgrid}),
where {lgrid} is a scalar cell array. The value of the scalar controls the density of the frequency grid by setting the number of samples used along the frequency axis.
[b,err] = returns the unweighted approximation error magnitudes. gremez(...)
err contains one element for each independent approximation error returned by the function.
[b,err,res] = returns the structure gremez(...)
res comprising optional results computed by gremez. res contains the following fields.
gremez is also a "function function", allowing you to write a function that defines the desired frequency response.
b = returns a length N+1 FIR filter which has the best approximation to the desired frequency response as returned by the user-defined function gremez(n,f,fresp,w)
fresp. gremez uses the following syntax to call fresp
fresp is the string variable that identifies the function that you use to define your desired filter frequency response.
n is the filter order.
f is the vector of frequency band edges which must appear monotonically between 0 and 1, where 1 is one-half of the sampling frequency. The frequency bands span f(k) to f(k+1) for k odd. The intervals f(k+1) to f(k+2) for k odd are "transition bands" or "don't care" regions during optimization.
gf is a vector of grid points that have been chosen over each specified frequency band by gremez, and determines the frequencies at which gremez evaluates the response function.
w is a vector of real, positive weights, one per band, for use during optimization. w is optional in the call to gremez. If you do not specify w, it is set to unity weighting before being passed to fresp.
dh and dw are the desired frequency response and optimization weight vectors, evaluated at each frequency in grid gf.
gremez includes a predefined frequency response function named 'remezfrf2'. You can write your own based on the simpler 'remezfrf'. See the help for private/remezfrf for more information.
b = specifies optional arguments gremez(n,f,{fresp,p1,p2,...},w)
p1, p2,..., pn to be passed to the response function fresp.
b = is a synonym for gremez(n,f,a,w)
b = gremez(n,f,{'remezfrf2',a},w), where a is a vector containing your specified response amplitudes at each band edge in f. By default, gremez designs symmetric (even) FIR filters. 'remezfrf2' is the predefined frequency response function. If you do not specify your own frequency response function (the fresp string variable), gremez uses 'remezfrf2'.
b = gremez(...,'h') and b = gremez(...,'d') design antisymmetric (odd) filters. When you omit the 'h' or 'd' arguments from the gremez command syntax, each frequency response function fresp can tell gremez to design either an even or odd filter. Use the command syntax sym = fresp('defaults',{n,f,[],w,p1,p2,...}). gremez expects fresp to return sym = 'even' or sym = 'odd'. If fresp does not support this call, gremez assumes even symmetry.
For more information about the input arguments to gremez, refer to remez.
See Also
remez, cremez, butter, cheby1, cheby2, ellip, freqz, filter, firls, and fircls in your Signal Processing Toolbox documentation
Reference
Shpak, D.J. and A. Antoniou, "A generalized Remez method for the design
of FIR digital filters," IEEE Trans. Circuits and Systems, pp. 161-174,Feb. 1990.
| get | hex2num | ![]() |