Signal Processing Toolbox | Help Desk |
cremez
Complex and nonlinear-phase equiripple FIR filter design
b = cremez(n,f,'fresp
') b = cremez(n,f,'fresp
',w) b = cremez(n,f,{'fresp
',p1,p2,...},w) b = cremez(n,f,a,w) b = cremez(...,'sym
') b = cremez(...,'debug
') b = cremez(...,'skip_stage2') [b,delta,opt] = cremez(...)
cremez
allows arbitrary frequency-domain constraints to be specified for the design of a possibly complex FIR filter. The Chebyshev (or minimax) filter error is optimized, producing equiripple FIR filter designs.
b = cremez(n,f,'fresp
')
returns a length n+1
FIR filter with the best approximation to the desired frequency response as returned by function fresp
. f
is a vector of frequency bandedge pairs, specified in the range -1 and 1, where 1 corresponds to half the sampling frequency (the Nyquist frequency). The frequencies must be in increasing order, and f
must have even length. 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.
b = cremez(n,f,'fresp
',w)
uses the real, non-negative weights in vector w
to weight the fit in each frequency band. The length of w
is half the length of f
, so there is exactly one weight per band.
b = cremez(n,f,{'fresp
',p1,p2,...},...)
supplies optional parameters p1
, p2
, ..., to the frequency response function fresp
. Predefined frequency response functions for 'fresp'
include the following design filters with the appropriate frequency response. For all of the predefined frequency response functions, the symmetry option 'sym'
defaults to 'even'
if no negative frequencies are contained in f
and d = 0
; otherwise 'sym'
defaults to 'none'
. (See the 'sym'
option below for details.) For all of the predefined frequency response functions, d
specifies a group-delay offset such that the filter response will have a group delay of n/2+d
in units of the sample interval. Negative values create less delay; positive values create more delay. By default, d = 0
.
lowpass, highpass, bandpass, bandstop
These functions share a common syntax, exemplified here by 'lowpass'
:
b = cremez(n,f,'lowpass',...)
and
b = cremez(n,f,{'lowpass',d},...)
design a linear-phase (n/2+d
delay) filter.
multiband
designs a linear-phase frequency response filter with arbitrary band amplitudes.
b = cremez(n,f,{'multiband',a},...)
and
b = cremez(n,f,{'multiband',a,d},...)
specify vector a
containing the desired amplitudes at the band edges in f
. The desired amplitude at frequencies between pairs of points (
f
(k),
f
(k+1))
for k
odd is the line segment connecting the points (
f
(k),
a
(k))
and (
f
(k+1),
a
(k+1))
.
differentiator
designs a linear-phase differentiator. For these designs, zero-frequency must be in a transition band, and band weighting is set to be inversely proportional to frequency.
b = cremez(n,f,{'differentiator',Fs},...)
and
b = cremez(n,f,{'differentiator',Fs,d},...)
specify the sample rate Fs
used to determine the slope of the differentiator response. If omitted, Fs
defaults to 1.
hilbfilt
designs a linear-phase Hilbert transform filter response. For Hilbert designs, zero-frequency must be in a transition band.
b = cremez(n,f,'hilbfilt',...)
and
b = cremez(N,F,{'hilbfilt',d},...)
design a linear-phase (n/2+d
delay) Hilbert transform filter.
b = cremez(n,f,a,w)
is a synonym for b = cremez(n,f,{'multiband',a},w)
.
b = cremez(...,
'sym'
)
imposes a symmetry constraint on the impulse response of the design, where 'sym'
may be
none
indicates no symmetry constraint
This is the default if any negative band edge frequencies are passed, or if '
fresp
'
does not supply a default.
even
indicates a real and even impulse response
This is the default for highpass, lowpass, bandpass, bandstop, and multiband designs.
odd
indicates a real and odd impulse response
This is the default for Hilbert and differentiator designs.
real
indicates conjugate symmetry for the frequency response
'sym'
option other than 'none'
is specified, the band edges should only be specified over positive frequencies; the negative frequency region will be filled in from symmetry. If not specified, the 'fresp'
function will be queried for a default setting.
b = cremez(..., 'skip_stage2')
disables the second-stage optimization algorithm, which executes only when cremez
determines that an optimal solution has not been reached by the standard Remez error-exchange. Disabling this algorithm may increase the speed of computation, but may incur a reduction in accuracy. By default, the second-stage optimization is enabled.
b = cremez(...,
'debug'
)
enables the display of intermediate results during the filter design, where 'debug'
may be one of 'trace'
, 'plots'
, 'both'
,
or 'off'
. By default, it is set to 'off
'.
Note that any combination of the 'sym
', 'debug
', and 'skip_stage2
' options may be specified.
[b,delta] = cremez(...)
returns the maximum ripple height delta
.
[b,delta,opt] = cremez(...)
returns a structure opt
of optional results computed by cremez
and contains the following fields:
opt.fgrid
, frequency grid vector used for the filter design optimization
opt.H
, frequency response for each point in opt.fgrid
opt.error
, error at each point in opt.fgrid
opt.fextr
, vector of extremal frequencies
b = cremez(30,[-1 -0.5 -0.4 0.7 0.8 1],'lowpass'); freqz(b,1,512,'whole');User-definable functions may be used, instead of the predefined frequency response functions for
![]()
'fresp'
. The function is called from within cremez
using the following syntax:
[dh,dw] =
fresp
(n,f,gf,w,p1,p2,...)
where
n
is the filter order.
f
is the vector of frequency band edges that appear monotonically between -1 and 1, where 1 is the Nyquist frequency.
gf
is a vector of grid points that have been linearly interpolated over each specified frequency band by cremez
. gf
determines the frequency grid at which the response function must be evaluated.
w
is a vector of real, positive weights, one per band, used during optimization. w
is optional in the call to cremez
; if not specified, it is set to unity weighting before being passed to 'fresp'
.
dh
and dw
are the desired complex frequency response and band weight vectors, respectively, evaluated at each frequency in grid gf
.
p1
, p2
,..., are optional parameters that may be passed to 'fresp'
.
'fresp'
to determine the default symmetry property 'sym'.
This call is made using the syntax:
sym =
fresp
('defaults',{n,f,[],w,p1,p2,...})
The arguments may be used in determining an appropriate symmetry default as necessary. The function private/lowpass.m
may be useful as a template for generating new frequency response functions.
An extended version of the Remez exchange method is implemented for the complex case. This exchange method obtains the optimal filter when the equiripple nature of the filter is restricted to have n+2
extremals. When it does not converge, the algorithm switches to an ascent-descent algorithm that takes over to finish the convergence to the optimal solution. See the references for further details.
The following diagnostic messages arise from incorrect usage of cremez
:
Not enough input arguments. F must contain an even number of band edge entries. Band edges must be monotonically increasing. Expecting a string argument. Invalid argumentarg
specified. Invalid default symmetry optionsym
returned from response. functionfresp
. Must be one of 'none', 'real', 'even', or 'odd'. Frequency band edges must be in the range [-1,+1] for designs with SYM = 'sym
'. Frequency band edges must be in the range [0,+1] for designs with SYM = 'sym
'. Incorrect size of results from response functionfresp
. Sizes must be the same size as the frequency grid GF. Both -1 and 1 have been specified as frequencies in F, and the frequency spacing is too close to move either of them toward its neighbor. Internal error: Grid frequencies out of range. Internal error: domain must be "whole" or "half". Internal error: obtained a negative bandwidth. Internal error: two extremal frequecies at the same grid point. Internal error: dBrange must be > 0.
Window-based finite impulse response filter design-- standard response. |
|
Window-based finite impulse response filter design-- arbitrary response. |
|