Summary of filter design commands in Matlab
Dr. S. Kozaitis
Using Matlab, one can design low-pass digital filters of the following types:
1. Butterworth
2. Chebyshev (types 1 and 2)
3. Elliptic
4. Equiripple
5. Eigenfilter
In all cases, see the Matlab documentation for more information and uses.
Filter design (filter coefficients from specified frequency response)
Butterworth filters
Butterworth filters are called maximally flat because they have no ripples in the passband. They can be designed by the following command.
[B,A] = butter(N,Wn)
· N is the order of the filter
· Wn is the cutoff frequency, 0 Wn 1, where 1 represents p.
· B, and A are coefficients of the numerator and denominator respectively of the transfer function, in descending orders of z.
Chebyshev filters (type 1)
Chebyshev filters (type 1) have a constant ripple in the passband, but have a steeper slope in the transition region when compared to a Butterworth filter. The major difference between the even and odd orders is that the odd-order filters ripple down from the value at DC, and the even-order filters ripple up. The 3dB frequency is the frequency where the magnitude leaves the “passband box”. Therefore, for even-order filters, the gain at the 3dB frequency is the same as the DC gain, and for odd-order filters, the gain at the 3dB frequency is the ripple amount down from the DC gain. Chebyshev type 1 filters can be designed by the following command.
[B,A] = cheby1(N,R,Wn)
· N is the order of the filter
· R is the magnitude in dB in the passband.
· Wn is the cutoff frequency, 0 Wn 1, where 1 represents p.
· B, and A are coefficients of the numerator and denominator respectively of the transfer function, in descending orders of z.
Chebyshev filters (type 2)
Chebyshev filters (type 2) are similar to the type 1 filters, but have a constant ripple in the stopband. They can be designed using the following command.
[B,A] = cheby2(N,R,Wn)
· N is the order of the filter
· R is the magnitude in dB in the stopband.
· Wn is the cutoff frequency, 0 Wn 1, where 1 represents p.
· B, and A are coefficients of the numerator and denominator respectively of the transfer function, in descending orders of z.
Elliptic filters
Elliptic filters have equal ripple in the passband and stopbands. It often has a steeper transition region than the Chebyshev filters. Elliptic filters can be designed by the following command.
[B,A] = ellip(N,Rp,Rs,Wn)
· N is the order of the filter
· Rp is the magnitude in dB in the passband.
· Rs is the magnitude in dB in the stopband.
· Wn is the cutoff frequency, 0 Wn 1, where 1 represents p.
· B, and A are coefficients of the numerator and denominator respectively of the transfer function, in descending orders of z.
LMS filters
LMS filters are those that minimize the MSE between the desired and actual frequency response given for a specific filter order.
[B,A] = invfreqz(H,W,NB,NA)
· H is the desired complex frequency response (positive frequencies are sufficient)
· W contains the frequencies in radians/sec
· NB is the order of B.
· NA is the order of A.
· B, and A are coefficients of the numerator and denominator respectively of the transfer function, in descending orders of z.
Equiripple filters
Equiripple filters minimize the maximum error in the stopband. These filters have sidelobes of constant height. Filters that minimize the MSE between a desired and actual frequency response often have large sidelobes. The equiripple filter equalizes the height of the ripples at the expense of MSE.
B = remez(N,F,A)
· N is the order of the filter.
· F is a vector that contains pairs of frequencies corresponding to frequency bands.
· A is a vector the same length of F, that contains the corresponding normalized amplitudes.
· B contains the filter coefficients.