Length of impulse response of discrete-time filter System object
This example requires DSP System Toolbox™ software.
Design a 4th-order lowpass elliptic filter with a cutoff frequency of 0.4 rad/sample. Specify 1 dB of passband ripple and 60 dB of stopband attenuation. Design the filter in pole-zero-gain form and obtain the second order section matrix using the
zp2sos function. Create a biquad filter System object and input the System object to
[z,p,k] = ellip(4,1,60,.4); [sos,g] = zp2sos(z,p,k); hBqdFilt = dsp.BiquadFilter('Structure','Direct form I',... 'SOSMatrix', sos,... 'ScaleValues',g); len = impzlength(hBqdFilt)
len = 80
Design an IIR Butterworth and an FIR equiripple filter for data sampled at 1 kHz. Set the passband frequency is 100 Hz and the stopband frequency is 150 Hz. Set the passband ripple to 0.5 dB and the stopband attenuation to 60 dB. Create System objects for the filters and compare the filter impulse response sequence lengths.
d = fdesign.lowpass('Fp,Fst,Ap,Ast',100,150,0.5,60,1000); Hd1 = design(d,'butter','SystemObject',true); Hd2 = design(d,'equiripple','SystemObject',true); len = [impzlength(Hd1) impzlength(Hd2)]
len = 1×2 183 49
sysobj— Filter System object
Input filter, specified as one of the following filter System objects:
tol— Tolerance for IIR filter effective impulse response length
5e-5(default) | positive scalar
Tolerance for IIR filter effective impulse response length, specified as a positive
number. The tolerance determines the term in the absolutely summable sequence after
which subsequent terms are considered to be 0. The default tolerance is
5e-5. Increasing the tolerance returns a shorter effective impulse
response sequence length. Decreasing the tolerance returns a longer effective impulse
response sequence length.
arithType— Arithmetic type
Arithmetic used in the filter analysis, specified as
'Fixed'. When the arithmetic
input is not specified and the filter System object is unlocked, the analysis tool assumes a double-precision filter. When the
arithmetic input is not specified and the System object is locked, the function performs the analysis based on the data type of
the locked input.
'Fixed' value applies to filter System objects with fixed-point
'Arithmetic' input argument is specified as
'Fixed' and the filter object has the data type of the
coefficients set to
'Same word length as input', the arithmetic
analysis depends on whether the System object is unlocked or locked.
unlocked –– The analysis object function cannot determine the coefficients data type. The function assumes that the coefficients data type is signed, has a 16-bit word length, and is auto scaled. The function performs fixed-point analysis based on this assumption.
locked –– When the input data type is
'single', the analysis object function cannot
determine the coefficients data type. The function assumes that the data
type of the coefficients is signed, has a 16-bit word length, and is auto
scaled. The function performs fixed-point analysis based on this
To check if the System object is locked or unlocked, use the
When the arithmetic input is specified as
'Fixed' and the filter
object has the data type of the coefficients set to a custom numeric type, the object
function performs fixed-point analysis based on the custom numeric data type.
len— Length of impulse response
Length of the impulse response, specified as a positive integer. For stable IIR
filters with absolutely summable impulse responses,
returns an effective length for the impulse response beyond which the coefficients are
essentially zero. You can control this cutoff point by specifying the optional
tol input argument.