Example: confidence

Lab Report 5 IIR & FIR Filter Design using MATLAB

Abu Dhabi UniversityCEN 464 - Digital Signal ProcessingLab Report 5 IIR & FIR Filter Design using MATLABA uthors:Muhammad Obaidullah 1030313 Supervisor:Dr. Mohammed Assad GhazalSection 1 June 9, 2014 Contents1 Objectives of the lab22 List of equipment used23 FIR Filter Design By Windowing Hamming Window .. Lowpass Impulse Responsehd(n) .. Display Frequency domain of a Filter .. Specifications .. parameters for the designed Filter .. Kaiser Window .. the FIR high-pass Filter using Kaiser window.. Band Reject Filter .. Code: .. : .. Band Pass Filter .. Code: .. : ..84 FIR Filter Design By MATLAB FDA Specifications of the Desired Filter .. Window .. Window .. Window .. Window .. 125 IIR Filter Design By MATLAB FDA Filter .. Type I Filter .. Type II Filter .. Filter .. 166 Conclusion171 AbstractIn this lab we were introduced to different Filter Design using MATLAB toolboxes, complexfeatures, and advanced functions.

4 FIR Filter Design By MATLAB FDA Tool Filter Design and Analysis Toolbox in MATLAB is a very powerful but user-friendly GUI lter designer which can be used to design almost all popular lters very easily and conveniently.

Tags:

  Design

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of Lab Report 5 IIR & FIR Filter Design using MATLAB

1 Abu Dhabi UniversityCEN 464 - Digital Signal ProcessingLab Report 5 IIR & FIR Filter Design using MATLABA uthors:Muhammad Obaidullah 1030313 Supervisor:Dr. Mohammed Assad GhazalSection 1 June 9, 2014 Contents1 Objectives of the lab22 List of equipment used23 FIR Filter Design By Windowing Hamming Window .. Lowpass Impulse Responsehd(n) .. Display Frequency domain of a Filter .. Specifications .. parameters for the designed Filter .. Kaiser Window .. the FIR high-pass Filter using Kaiser window.. Band Reject Filter .. Code: .. : .. Band Pass Filter .. Code: .. : ..84 FIR Filter Design By MATLAB FDA Specifications of the Desired Filter .. Window .. Window .. Window .. Window .. 125 IIR Filter Design By MATLAB FDA Filter .. Type I Filter .. Type II Filter .. Filter .. 166 Conclusion171 AbstractIn this lab we were introduced to different Filter Design using MATLAB toolboxes, complexfeatures, and advanced functions.

2 Advanced MATLAB tools such as fdatool GUI were used todesign the Finite Impulse Response Filters. The windows which were used are Kaiser, Hammingand Hanning. The advantage of designing a Filter using MATLAB is simplicity and very easytuning of the Filter parameters. With the click of few buttons, the Filter parameters an bechanged to get a whole new Design and even the computational powers of MATLAB can helpthe user tune certain parameters to get the desired results. Finally, in this lab we will compareand contrast between all of these methods of Filter Design and give our Objectives of the lab Understand and recognize the parameters needed for designing the FIR Filter . Be able to Design an Finite Impulse Response Filter using windowing techniques. Be able to Design and tune an Finite Impulse Response Filter using MATLAB FDA Tool. Have a clear distinction between the FIR and IIR Filter List of equipment used A Computer.

3 MATLAB . Filter Design & Analysis FIR Filter Design By Windowing TechniquesIn the first part of the lab, we will be designing different filters by the traditional windowingtechniques. The general steps are to first determine the specifications of the Filter using the equationsrelated to the Filter and then inputting the information in the MATLAB via a code for simulatingthe provides several functions to easily Design and implement window filters. A brief listis given below: [1] boxcar(M)returns the M-point rectangular window function in array w. triang(M)returns the M-point Bartlett (triangular) window function in array w. hanning(M)returns the M-point Hanning window function in array w. hammimg(M)returns the M-point Hamming window function in array w. blackman(M)returns the M-point Blackman window function in array Hamming Ideal Lowpass Impulse Responsehd(n)To start designing the lowpass FIR filters, an Ideal low-pass impulse response should be hd = i d e a ll p (wc , M)% Ideal LowPass f i l t e r computation3% % [ hd ] = i d e a ll p (wc , M)5% hd = i d e a l impulse response between 0 to M 1% wc = c u t o f f frequency in radians7%M = length of the i d e a l f i l t e r%9alpha = (M 1) /2;n = [ 0 : 1 : (M 1) ]11M = nalpha + eps ; % add smallest number to avoid divide by zerohd = sin (wc M).

4 / ( pi M) ; To Display Frequency domain of a filterThis function returns the magnitude response in absolute as well as in relative dB scale, the phaseresponse, and the group delay [ db , mag, pha , grd , w] = freqzm (b , a )2% Modified version of freqz sunroutine% 4% [ db , mag, pha , grd ,w] = freqzm (b , a )% db = Relative magnitude in dB computed over 0 to pi radians6% mag = absolute magnitude computed over 0 to pi radians% pha = Phase response in radians over 0 to pi radians8% grd = group delay over 0 to pi radians% w = 501 frequency samples between 0 to pi radians10% b = numerator polynimial of H( z )( f o r FIR : b=h)% a = denominator polynomial of H( z ) ( f o r FIR : a =[1])12%[H,w] = freqz (b , a ,1000 , w h o l e ) ;14H = (H( 1 : 1 : 5 0 1 ) );w = (w( 1 : 1 : 5 0 1 ) );16mag = abs (H) ;db = 20 log10 ((mag+eps ) /max(mag) ) ;18pha = angle (H) ;grd = grpdelay (b , a ,w) ;20% End of Given Specificationswp= ,ws= ,Rp= ,As= 50dBWe entered the following code and the result produced was = pi ; ws = pi ;2trwidth = ws wp;M = c e i l ( pi / trwidth ) +1;4n = [ 0 : 1 :M 1];wc = (ws+wp) /2;6hd = i d e a ll p (wc ,M) ;wham = (hamming(M) ) ;8h = hd.

5 Wham ;[ db , mag, pha , grd ,w] = freqzm (h , [ 1 ] ) ;10% plotssubplot (1 ,1 ,1)12subplot (2 ,2 ,1) ; stem (n , hd) ; t i t l e ( Ideal Impulse Response )axis ( [ 0 M 1 0 . 3 ] ) ; xlabel ( n ) ; ylabel ( hd(n) )14subplot (2 ,2 ,2) ; stem (n , wham) ; t i t l e ( Hamming Window )axis ( [ 0 M 1 0 1 . 1 ] ) ; xlabel ( n ) ; ylabel ( w(n) )16subplot (2 ,2 ,3) ; stem (n , h) ; t i t l e ( Actual Impulse Response ) ;axis ( [ 0 M 1 0 . 3 ] ) ; xlabel ( n ) ; ylabel ( h(n) ) ;18subplot (2 ,2 ,4) ; plot (w/pi , db) ; t i t l e ( Magnitude Response in dB ) ;grid20axis ( [ 0 1 100 10]) ; xlabel ( frequency in pi units ) ;ylabel ( Decibels )Figure 1: This figure was generated after running the code for given specifications. The figureshows the ideal Filter impulse response, the hamming window applied Filter impulse response, theactual hamming window in time domain and the magnitude response of the hamming Finding parameters for the designed filterFind the value ofM,Rp, andAsof the designed Filter in the procedure41% For Determining s i z e of f i l t e r.

6 ( F i l t e r Taps )M = c e i l ( pi / trwidth ) +1;3% Print Size of F i l t e rM5deltaw = 2 pi /1000;% Actual Passband Ripple7Rp = (min(db ( 1 :wp/ deltaw +1)) )% Min Stopband attenuation9As = round (max(db(ws/ deltaw +1:501) ) )Figure 2: MATLAB calculated all the Design parameters and the results is shown. Basically, thefilter size ( Filter Taps) will be 67, pass-band ripple will be , and the minimum stop-bandAttenuation will be Kaiser Design the FIR high-pass Filter using Kaiser Specifications:wp= ,ws= ,As= 50dB1% F i l t e r S p e c i f i c a t i o n swp = pi ;3ws = pi ;trwidth = ws wp;5% Finding F i l t e r Essential Parameters7M = c e i l (( As ) /( trwidth )+1) + 1;n = [ 0 : 1 :M 1];9wc = (ws+wp) /2;hd = i d e a ll p ( pi , M) i d e a ll p (wc ,M) ;11% Since As>5013 Beta = (As )15% Building the F i l t e rKaiserWindow = ( k a i s e r (M, Beta ) ) ;517h = hd.

7 KaiserWindow ;[ db , mag, pha , grd ,w] = freqzm (h , [ 1 ] ) ;19deltaw = 2 pi /1000;As = f l o o r (max(db ( 1 : 1 : ( wp/ deltaw )+1)) )21% Plotting the Results23subplot (2 ,2 ,1) ;stem (n , hd) ;25t i t l e ( Ideal Impulse Response )axis ( [ 0 M 1 0 . 5 ] ) ;27xlabel ( n ) ;ylabel ( hd(n) )29subplot (2 ,2 ,2) ;stem (n , KaiserWindow ) ;31t i t l e ( Kaiser Window Graph )axis ( [ 0 M 1 0 1 . 1 ] ) ;33xlabel ( n ) ;ylabel ( w(n) )35subplot (2 ,2 ,3) ;37stem (n , h) ;t i t l e ( Actual Impulse Response ) ;39axis ( [ 0 M 1 0 . 5 ] ) ;xlabel ( n ) ;41ylabel ( h(n) ) ;subplot (2 ,2 ,4) ;43plot (w/pi , db) ;axis ( [ 0 1 130 10]) ;45t i t l e ( Magnitude Response in dB ) ;grid on ;6 Figure 3: As we can see from the figure that the high pass Kaiser Filter was designed successfullymeeting the Design Band Reject The Code:wp1= pi ; ws1= pi ;2wp2= pi ; ws2= pi ;%only one t r a n s i t i o n bandwidth4% allowed in window designtrwidth=min(wp1 ws1 , ws2 wp2) ;6M=c e i l (11 pi / trwidth ) +1;n=[0:M 1];8wc1=(ws1+wp1) /2; %i d e a l c u t o f f frequency 1wc2=(ws2+wp2) /2; %i d e a l c u t o f f frequency 210hd=i d e a ll p ( pi ,M) i d e a ll p (wc2 ,M) i d e a ll p (wc1 ,M) ;wblackman=(blackman (M) ) ;12h=hd.

8 Wblackman ;f i g u r e (1) ; stem (n , h) ; t i t l e ( h(n) )14f i g u r e (2) ; freqz (h , [ 1 ] ) Result:7 Figure 4: The impulse response of theband reject 5: The magnitude response of the band re-ject Filter and the phase response. We can clearlysee that the phase is linear in pass-bands, whichis Band Pass The Code:wp1= pi ; ws1= pi ;2wp2= pi ; ws2= pi ;%only one t r a n s i t i o n bandwidth4% allowed in window designtrwidth=min(wp1 ws1 , ws2 wp2) ;6M=c e i l (11 pi / trwidth ) +1;n=[0:M 1];8wc1=(ws1+wp1) /2; %i d e a l c u t o f f frequency 1wc2=(ws2+wp2) /2; %i d e a l c u t o f f frequency 210hd= i d e a ll p (wc2 ,M) i d e a ll p (wc1 ,M) ;wblackman=(blackman (M) ) ;12h=hd . wblackman ;f i g u r e (1) ; stem (n , h) ; t i t l e ( h(n) )14f i g u r e (2) ; freqz (h , [ 1 ] ) Result:8 Figure 6: The impulse response of theband pass 7: The magnitude response of the bandpass Filter and the phase response.

9 We can clearlysee that the phase is linear in pass-bands, whichis FIR Filter Design By MATLAB FDA ToolFilter Design and Analysis Toolbox in MATLAB is a very powerful but user-friendly GUI filterdesigner which can be used to Design almost all popular filters very easily and conveniently. Differentwindowing techniques such as Hanning, Hamming, Bartlett, Rectangular, Blackman etc. can beapplied to band-pas, band-reject, low-pass, high-pass etc. So all in all, it offers much flexibilitywhen it comes to choosing the right Filter and implementing it and it is a real time saver for apracticing Specifications of the Desired Filter Low-pass Filter fcut of f= 10 Khz Fsampling= 50 Khz M= Rectangular WindowIndeed, the attenuation was -20dB in the stopband and the transition band was very sharp. Thephase response is linear in the pass-band and the Filter has a constant group delay, meaning thatall frequencies get delayed by the same amount as we can see from the 8: The magnitude response, phase response and group delay of the low pass Filter designedusing FDA Tool in MATLAB with rectangular Hanning WindowIndeed, the attenuation was below -40dB in the stopband as expected of hanning window butthe transition band was not sharp.

10 The phase response is linear in the pass-band and the Filter hasa constant group delay, meaning that all frequencies get delayed by the same amount as we can seefrom the 9: The magnitude response, phase response and group delay of the low pass Filter designedusing FDA Tool in MATLAB with hanning Hamming WindowIndeed, the attenuation was below -60dB in the stopband as expected of hamming window butthe transition band was even more smooth than rectangular or hanning. The phase response islinear in the pass-band and the Filter has a constant group delay, meaning that all frequencies getdelayed by the same amount as we can see from the 10: The magnitude response, phase response and group delay of the low pass Filter designedusing FDA Tool in MATLAB with hamming Blackman WindowIndeed, the attenuation was below -80dB in the stopband as expected of blackman window butthe transition band was even more smooth than all.


Related search queries