Design IIR FIR based on Matlab

Design for IIR and FIR based on Matlab


This report proposes designing methods for infinite impulse response (IIR) digital filters such as Butterworth lowpass filter and elliptic lowpass filter and linear-phase finite impulse response (FIR) highpass digital filter based on Matlab. Commonly, designing analog filter is the first step, and then using transformation of frequency band makes analog filter transfer to digital filter. So, the methods of designing the digital filter are bilinear transformation and. Another linear-phase FIR highpass digital filter was designed by following windows function: Hamming, Hann, Blackman, and Kaiser. This study showed some characteristics on different windows function. To some extent, Kasier window appears superiority.


In the report using types of digital filter functions to practice to get realization based on Matlab. Through designing certain linear phase IIR and FIR filter is to find some effective and simple methods in different occasion. In the following, I would illustrate the lowpass IIR digital transfer function to meet given specifications by bilinear transformation method and impulse invariance method. And through carrying out the order of the analog filter using the given formula, and then design the analog filter. Use transfer function to calculate and make the analog filter transfer to digital filter using Matlab. At last, obtaining the gain and phase responses.

In addition to design IIR filter, I also tried to simulate finite impulse responses (FIR). Though they both are digital system which used to filter discrete-time signal and deal with the sampling data by mathematical method and would achieve the frequency-domain filtering, the advantages of FIR shows obviously. During the design of FIR digital filter, it does not need analog filter, realize by multiphase and more stable than IIR's properties. On the other hand, the methods of designing FIR filter may use simple windows function. In the report, I also comment on and compare four windows functions under the same cases.

1 Background theory

1.1 Butterworth lowpass

Butterworth lowpass filter is one kinds of analog filter. Main feature is its passband and stopband have a flat amplitude response. The Butterworth approximation results from the requirements that the magnitude responses be maximally flat in both the passband and the the stopband[ Jackson L.B, 1989]. Its squared magnitude response is of the form: Hc(jw)2=11+(??c)2N . N is the order value of the filter.?c is a cut-off frequency. From here, the order N has a formula to describe:N=log10(10Rp/10-1)/(10As/10-1)2log10(Op-Os). Butterworth filter's properties are: a. it has the most stable frequency in the passband. b. the order is higher, the feature of filter is closer to rectangular(fig.1.1). In the real design, we can find the function buttap using the Matlab Signal Processing Toolbox to realize the design of Butterworth analog lowpass filter. The form of buttap is [z,p,k]=buttap(N); z, p, k are respectively zero-point, pole-point and gain of the filter. And last using bilinear transformation method converts analog filters into digital filters.

The program code is given by:

fs=30;ft=100; A=sqrt(10^5); fc=10;

ws=2*pi*fs/ft; omegas=tan(ws/2);

epsi=sqrt(10^0.04-1); v=sqrt(A^2-1)/epsi; u=omegas/omegac;






plot(w/pi,20*log10(abs(G)));title('Butterworth_gain responses');grid t= phase(G);subplot(2,1,2);

plot(w/pi,t);title('Butterworth_phase responses');grid (see fig1.1.1)

1.2 Elliptic lowpass filter

Elliptic lowpass filter's passband ripple is equal to stopband ripple. The transfer function of an elliptic filter meets a given set of filter specifications, passband edge frequency Op, stopband edge frequency Os, passband ripple e, and minimum stopband attenuation A, with the lowest filter order N[Mitra.S,2006]. So, the square-magnitude response of elliptic lowpass filter is given by: where N is the order of elliptic lowpass and,RN(O) denotes the jacobian elliptic function of order N. And determine N =2log10(4/k1)log10(1/?), where k1 is the discrimination parameter and ? is computed as follows:?=?0+2(?0)5+15(?0)9+150(?0)13.

The program code is given by: bilinear transformation method


ws=2*pi*fs/ft; omegas=2*tan(ws/2);

wp=2*pi*fp/ft; omegap=2*tan(wp/2);









plot(w/pi,20*log10(abs(H)));title('Elliptic gain responses__bilinear');grid


plot(w/pi,t);title('Elliptic phase responses__bilinear');grid

(see fig1.2.1)

fs=30; fp=10; ft=100; Rp=0.4;As=50;

ws=2*pi*fs/ft; wp=2*pi*fp/ft; A=sqrt(10^(As/10));

k=wp/ws; k0=sqrt(1-k^2);





[z,p,k]=ellipap(N,Rp,As); [b,a]=zp2tf(z,p,k); [B,A]=impinvar(b,a,fs);

plot(w/pi,20*log10(abs(H)));title('Elliptic gain responses__impulse invariance');grid


plot(w/pi,t);title('Elliptic phase responses__impulse invariance');grid

(see f ig1.2.2)

1.3 linear-phase FIR highpass filter design

The program code is given by:

ws=0.4*pi; wp=0.55*pi;

Rp=0.1; As=42;

width=wp-ws; Wn=(wp+ws)/2;




plot(w/pi,20*log10(abs(G)));title('hanning window__gian response');grid

subplot(2,1,2); plot(B);title('hanning window__phase response');grid

b) Hamming window for FIR highpass filters

Hamming window and Hanning window are cosine window, but they have different weighting coefficients.

The program code is given by:

ws=0.4*pi; wp=0.55*pi;


width=wp-ws; Wn=(wp+ws)/2;



plot(w/pi,20*log10(abs(G)));title('hanning window__gian response');grid


plot(B);title('hamming window__phase response');grid

c) Blackman window for FIR highpass filter

The Blackman window has the least side lobe peak among the windows, while it offers wider main lobe width [Shayesteh, M.G. and Mottaghi-Kashtiban, M,2009]

ws=0.4*pi; wp=0.55*pi;

Rp=0.1; As=42;




plot(w/pi,20*log10(abs(G)));title('blackman__gian response');grid


plot(B);title('blackman__phase response');grid

d) Kaiser window for FIR highpass filter

Kaiser window is a well known flexible window and widely used for the spectrum analysis and FIR filter design applications since it achieves close approximation to the discrete prolate spheroidal functions that have the maximum energy concentration in the mainlobe [Avci.K., Nacaroglu.A, 2008].

The program code is given by:

ws=0.4*pi; wp=0.55*pi;

Rp=0.1; As=42;

width=wp-ws; delts=10^(-As/20);

[N,Wn,BTA,filtype] = kaiserord( [0.4 0.55], [1 0], [delts delts]);

B = fir1(N, width,'high' ,kaiser( N+1,BTA));


plot(w/pi,20*log10(abs(G)));title('Kaiser__gian response');grid


2. Discussion

2.1 Butterworth lowpass filter

As we known, Butterworth lowpass filter has very stable feature. Its amplitude function is controlled by the order value N. As a result of program of Butterworth, it is an all-pole filter. According to its specifications Op,?p,Os,?s,determine the order N.

2.2 Elliptic lowpass filter

Compare with other kinds of filters, lowpass filter has the smallest passband and stopband fluctuations under they have the same order elliptic. In this report, there are two methods to design elliptic filter. I got two different N value.

2.3 Window functions design for FIR filter

Window functions are for adding windows to deal with ideal filter. Commenly, its Matlab tool functions are fir1, fir2 and Kasiserord. When design FIR filter use window functions, we first should confirm the types of windows and choose appropriate windows to design. Hanning , Hamming, Blackman these three window functions have their own main or side lobe coefficient, but Kaiser window function's main or side lobe coefficient is flexible. Whereas, the coefficients relate with the length of window functions N. Increasing the length N or decreasing the main lobe cannot decrease side-lobe amplitude attenuation.

2.4 Comparison of IIR and FIR filters

On the methods of design, although the methods of IIR seem to a little simple, the filter is still an analog filter. Such as lowpass, highpass, passband, stopband. And its phase is difficult to control; order value is less than FIR. On the other hand, FIR appears always stable and it may be more flexible. About design tool, IIR filter may use the results by means of simulation. Therefore, it has effective formula to calculate exactly. But, FIR filter does not have regular formula. Although window functions methods afford formula to window function, there is no formula to calculate passband, stopband, attenuation.


Through studying and practise to the digital filter, I got realization based on Matlab for designing. During the progress, types of properties of filters cause the design methods to be different and they have their own features. Lowpass IIR digital need transfer function to meet given specifications. After calculate the order of the analog filter by the given formula, and then design the analog filter. About design for FIR digital filter, the window functions methods of designing should be concerned .Especially, Kaiser window function appears its advantages in the design. At last, there is a comparison between IIR and FIR filter. According this, we can find the most appropriate function to design filter, and choose right filter in appropriate occasion.


[1] Avci, K.; Nacaroglu, A.; 2008, Cosine Hyperbolic Window Family

with its Application to FIR Filter Design, Vol.7-11 April Pp:1 - 6

[2] Jackson L.B, 1989, Digital Filters and Signal Processing ,published by Kluwer Academic Publisher, USA

[3]Mitra.S,2006,Digital signal processing-A Computer Based Approach, published by McGRAW-HILL,New York

[4]Shayesteh, M.G.; Mottaghi-Kashtiban, M.18-23 May 2009,An efficient window function for design of FIR filters using IIR filters,EUROCON 2009 IEEE,Pp:1443 - 1447

Please be aware that the free essay that you were just reading was not written by us. This essay, and all of the others available to view on the website, were provided to us by students in exchange for services that we offer. This relationship helps our students to get an even better deal while also contributing to the biggest free essay resource in the UK!