Digital Filter Design Using Matlab By Timothy J. Schlichter
EE 4000 Introduction to Digital Filtering 5/2/99
Submitted to: Dr. Joseph Picone Mississippi State University
Department of Electrical and Computer Engineering
EXECUTIVE SUMMARY
A fundamental aspect of signal processing is filtering. Filtering involves the manipulation of the spectrum of a signal by passing or blocking certain portions of the spectrum,
depending on the frequency of those portions. Filters are designed according to what kind of manipulation of the signal is required for a particular application. Digital filters are implemented using three fundamental building blocks: an adder, a multiplier, and a delay element.
The design process of a digital filter is long and tedious if done by hand. With the aid of computer programs performing filter design algorithms, designing and optimizing filters can be done relatively quickly. This paper discusses the use of Matlab, a mathematical software package, to design, manipulate, and analyze digital filters.
The design options in Matlab allow the user to either create a code for designing filters that calls built-in functions, or to design filters in Sptool, a graphical user interface. Each of these methods are examined in this paper. The strengths and weaknesses of each are detailed in the following discussion.
This paper concludes with a discussion of how the data given by Matlab for various filters can be used to implement filters on real digital signal processors. Matlab provides all the information necessary for building a hardware replica of the filter designed in software. TABLE OF CONTENTS
1. Abstract……………………………………………………………..4 2. Introduction. ………………………………………………………..4 3. Lowpass Filter Design………………………………………………7 4. Highpass and Bandpass Filter Design………………………………11 5. Sptool……………………………………………………………….13 6. Future Directions……………………………………………………16 7. Acknowledgments…………………………………………………..16 8. References…………………………………………………………..16 9. Appendix…………………………………………………………….17 Abstract
Matlab provides different options for digital filter design, which include function calls to filter algorithms and a graphical user interface called Sptool. A variety of filter design algorithms are available in Matlab for both IIR and FIR filters. This paper discusses the different options in Matlab and gives examples of lowpass, highpass, and bandpass filter designs.
Results show that the graphical user interface Sptool is a quicker and simpler option than the option of making function calls to the filter algorithms. Sptool has a more user-
friendly environment since the spectrum of the filter is immediately displayed to the user, and the user can quickly zoom in and examine particular areas of interest in the spectrum (i.e. the passband). However, the shortcoming of Sptool is that it only displays the magnitude response of the filter, not the phase response. Introduction
A key element in processing digital signals is the filter. Filters perform direct
manipulations on the spectra of signals. To completely describe digital filters, three basic elements (or building blocks) are needed: an adder, a multiplier, and a delay element. The adder has two inputs and one output, and it simply adds the two inputs together. The multiplier is a gain element, and it multiplies the input signal by a constant. The delay element delays the incoming signal by one sample. Digital filters can be implemented using either a block diagram or a signal flow graph. Figure 1 shows the three basic elements in block diagram form, and Figure 2 shows them in signal flow graph form.
With the basic building blocks at hand, the two different filter structures can easily be implemented. These two structures are Infinite Impulse Response (IIR) and Finite Impulse Response (FIR), depending on the form of the system’s response to a unit pulse input. IIR filters are commonly implemented using a feedback (recursive) structure, while FIR filters usually require no feedback (non-recursive).
In the design of IIR filters, a commonly used approach is called the bilinear
transformation. This design begins with the transfer function of an analog filter, then performs a mapping from the s-domain to the z-domain. Using differential equations, it can be shown (Proakis 677) that the mapping from the s-plane to the z-plane is
This mapping results in a general form for an IIR filter with an arbitrary number of poles and zeros. The system response and the difference equation for this filter is as follows:
This system response can be easily realized using a signal flow graph
An FIR filter has a difference equation of
By taking the z-transform, the system response is
The realization of an FIR filter using a signal flow graph is straightforward.
Matlab has several design algorithms that can be used to create and analyze both IIR and FIR digital filters. The IIR filters that can be created in Matlab are Butterworth, Chebyshev type 1 and 2, and elliptic. The FIR filter algorithms in Matlab are equiripple, least squares, and Kaiser window. The Matlab code required to implement these filters involves bilinear transformations and function calls to analog prototype filters. The following sections give examples of Matlab implementation of the IIR filters listed above. Lowpass Filter Design
Using Matlab, a lowpass digital filter is designed using various analog prototypes: Chebyshev, Butterworth, and Elliptic. The optimum filter type is chosen on the basis of implementation complexity, magnitude response, and phase response. The design specifications for the filter are as follows: ? Cutoff frequency = 1000Hz ? Sample frequency = 8000Hz ? Passband ripple = 0.5dB ? Stopband attn. = 60dB ? Transition band = 100Hz Matlab Code (Chebyshev):
% Lowpass digital filter with Chebyshev-I analog prototype %
% Digital Filter Specifications:
wp = 0.125*2*pi; % digital passband frequency in Hz (normalized) ws = 0.1375*2*pi; % digital stopband frequency in Hz (normalized) Rp = 0.5; % passband ripple in dB As = 20; % stopband attenuation in dB % Analog Prototype Specifications: Fs = 1; T = 1/Fs;
OmegaP = (2/T)*tan(wp/2); % prewarp prototype passband frequency OmegaS = (2/T)*tan(ws/2); % prewarp prototype stopband frequency % Analog Chebyshev-1 Prototype Filter Calculation: [c, d] = chb1(OmegaP, OmegaS, Rp, As); % Bilinear Transformation: [b, a] = bilinear(cs, ds, Fs); %
[db,mag,pha,grd,w] = freqz(b,a); plot(w*8000/2/pi,db);
xlabel('frequency (Hz)'); ylabel('decibels'); title('Magnitude in dB');
This exact code is also used for the elliptic and Butterworth designs. The only change is in the filter calculations of each type. Instead of calling chb1(), the elliptic filter design calls a function “elliptic()” and the Butterworth design calls a function
“butterworth()”. See the appendix for the Matlab code of the function chb1(). The following figures show the magnitude and phase responses of each type of filter. Magnitude Response of Chebyshev Filter
Phase of Chebyshev Filter
Magnitude Response of Elliptic Filter
数字滤波器设计英文文献



