Top Banner
Chapter 6 Digital FIR Filter Design Design of FIR filter Symmetric FIR filter Asymmetric FIR filter M odd M Even M odd M Even Where ‘M’ – Length of the filter For Symmetric FIR filter, filter impulse response should satisfy the following condition, h (n) = h (M-1-n) For Asymmetric FIR filter, filter impulse response should satisfy the following condition, h (n) = - h(M-1-n) 6.1.1 Frequency Response of FIR filter [1]. Symmetric FIR filter 46
51

Design of FIR Filter

Apr 04, 2015

Download

Documents

rsenthil_1976
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Design of FIR Filter

Chapter 6 Digital FIR Filter Design

Design of FIR filter

Symmetric FIR filter Asymmetric FIR filter

M odd M Even M odd M Even

Where ‘M’ – Length of the filter

For Symmetric FIR filter, filter impulse response should satisfy the following condition,

h (n) = h (M-1-n)

For Asymmetric FIR filter, filter impulse response should satisfy the following condition,

h (n) = - h(M-1-n)

6.1.1 Frequency Response of FIR filter

[1]. Symmetric FIR filter

where

46

Page 2: Design of FIR Filter

Magnitude Response for both odd length and even length filters

The phase characteristic of the FIR filter for both ‘M’ odd and ‘M’ even is

[2]. Asymmetric FIR filter

For ‘M’ odd, the center point of the antisymmetric h(n) is n = (M-1)/2 and also

Frequency response is given by

Magnitude Response for both odd length and even length filters

47

Page 3: Design of FIR Filter

The phase characteristic of the FIR filter for both ‘M’ odd and ‘M’ even is

6.1.2. Selection of Filters

S.No Type of FIR filter Suitable to Design

1. Asymmetric Even HPF, BSF

2. Asymmetric Odd Not suitable for any type of filter design

3. Symmetric Even LPF,BPF

4. Symmetric Odd LPF, HPF, BPF, BSF

Note:

[1]. Asymmetric Even – Its frequency response is zero at ‘ω’ = 0 ,(i.e) H(ω) =0 for Low Pass Filter design. So it is not suitable for LPF and BPF design.

[2]. Asymmetric Odd - It is not suitable for any type of FIR filter design. The reason is

At ‘ω’ = 0 ,(i.e) H(ω) =0 not suitable for LPF and BPF design,

At ‘ω’ = π , (i.e) H(ω) =0 not suitable for HPF and BSF design.

[3]. Symmetric Even - it is suitable for LPF and BPF filter design. The reason is

At ‘ω’ = π , (i.e) H(ω) =0 not suitable for HPF and BSF design.

[4]. Symmetric Odd – It is suitable for all types of FIR filter design.

48

Page 4: Design of FIR Filter

6.1.3 Design Of FIR Filters Using Windowing Techniques

Procedure:

1. Find the Unit Sample Sequence from the given desired frequency response

where ‘n’ varies from - ∞ to + ∞ and –π ≤ω ≤ π.

2. To design finite length filter multiply the doubly infinte unit sample sequence

with finite length window function w(n).

3. Find the frequency response of the filter using

The unit sample response is of infinite duration and must be truncated

at some point n = M-1 to give a FIR filter of length ‘M”. There are different types of

window functions used to obtain FIR filter response from infinite impulse response.

49

Page 5: Design of FIR Filter

6.1.4. Different Types of Windowing Techniques

S.N Type of window

W(n), 0 ≤ n ≤ M-1

Transition Width Side Lobe Level in dB

1. Rectangular

W(n) = 1

4П/M - 13

2. Hanning

w(n) = 0.5- 0.5 cos(2Пn/(M-1))

8П/M - 32

3. Hamming

W(n) = 0.54 – 0.46 cos(2Пn/M-1))

8П/M - 43

4. Bartlett

W(n) = 1- ( 2 | n- (M-1)/2| ) / (M-1)

8П/M - 27

5. Blackmann

W(n) = 0.42 – 0.5 cos(2Пn/(M-1))+

0.08 cos(4Пn/(M-1))

12П/M - 58

50

Page 6: Design of FIR Filter

6.1.5. Scilab Implementation of Digital FIR Filter

Name

wfir — linear-phase FIR filters

Calling Sequence

[wft,wfm,fr]=wfir(ftype,forder,cfreq,wtype,fpar)

Parameters

ftype

string : 'lp','hp','bp','sb' (filter type)

forder

Filter order (pos integer)(odd for ftype='hp' or 'sb')

cfreq

2-vector of cutoff frequencies (0<cfreq(1),cfreq(2)<.5) only cfreq(1) is used when ftype='lp' or 'hp'

wtype

Window type ('re','tr','hm','hn','kr','ch')

fpar

2-vector of window parameters. Kaiser window fpar(1)>0 fpar(2)=0. Chebyshev window fpar(1)>0, fpar(2)<0 or fpar(1)<0, 0<fpar(2)<.5

wft

time domain filter coefficients

wfm

frequency domain filter response on the grid fr

fr

Frequency grid

51

Page 7: Design of FIR Filter

Description

Function which makes linear-phase, FIR low-pass, band-pass, high-pass, and stop-band filters using the windowing technique. Works interactively if called with no arguments.

Note: In order to explain the concept of Implementation of FIR filter using SciLab software two example problems are solved and the results are verfied by writing programs in SciLab5.

Problem 1.

A Low pass fitler is to be designed with the following desired frequency response

Determine the filter coefficients hd(n) if the window function is defined as,

[ That is Rectangular Window]

M = filter length = 5.

Sol:

52

Page 8: Design of FIR Filter

n = 0, hd(n ) = (1/4) = 0.25

since it is a symmetric filter,

hd(1 ) = hd(-1 ) = 0.225079

hd(2 ) = hd(-2 ) = 0.159154

h(n) = Fitler Impulse Response = hd(n )* w(n)

h(0) = hd(0 )*w(0) = 0.25

h(1) = hd(1 )*w(1) = 0.225079 = h (-1)

h(2) = hd(2 )*w(2) = 0.159154 = h (-2)

Note: In SciLab5 programming h(n) = {0.159154, 0.225079, 0.25, 0.225079, 0.159154}

h(1) = 0.159154 = h(5)

h(2) = 0.225079 = h(4)

h(3) = 0.25

53

Page 9: Design of FIR Filter

Problem 2.

A Low pass fitler is to be designed with the following desired frequency response

Determine the filter coefficients hd(n) if the window function is defined as,

[ That is Rectangular Window]

M = filter length = 5.

Sol:

54

Page 10: Design of FIR Filter

h(n) = Fitler Impulse Response = hd(n )* w(n)

h(0) = hd(0 )*w(0) = 0.75

h(1) = hd(1 )*w(1) = - 0.2250791 = h (-1)

h(2) = hd(2 )*w(2) = - 0.1591549 = h (-2)

Note: In SciLab5 programming

h(n) = { - 0.1591549, - 0.2250791,0.75,- 0.2250791, - 0.1591549}

h(1) = - 0.1591549 = h(5)

h(2) = - 0.2250791 = h(4)

h(3) = 0.75

55

Page 11: Design of FIR Filter

Program 1: This program used to generate digital FIR filter coefficients for the filter specifications given in problem 2.

//To Design a Digital FIR filter//High Pass Filter with cutoff frequency Wc = pi/4//In Scilab Wc = Wc/2 = pi/8//Normalized cutoff frequency Wc_norm = Wc/pi//In Matlab Filter order = Filter Length - 1//In Scilab Filter order = Filter Length

clear;clc;

forder = 5; //Filter Length M = 5 cfreq = [0.125,0]; // For LPF and HPF only first value of cfreq selected as cutoff frequency // Here cutoff frequency Wc_norm = cfreq(1) = 0.125

[wft,wfm,fr]=wfir('hp',forder,cfreq,'re',0);wft; // Time domain filter coefficientswfm; // Frequency domain filter valuesfr; // Frequency sample pointsplot(fr,wfm)

//RESULT/High pass filter coefficents//- 0.1591549 - 0.2250791 0.75 - 0.2250791 - 0.1591549 for cut off frequency 0.125//which is equivalent to pi/4

56

Page 12: Design of FIR Filter

Figure 1. Corresponding to Program 1 output.

57

Page 13: Design of FIR Filter

Program 2: Some properties in graphics window of Program 1 changed in the coding itself

//To Design a Digital FIR filter//High Pass Filter with cutoff frequency Wc = pi/4//In Scilab Wc = Wc/2 = pi/8//Normalized cutoff frequency Wc_norm = Wc/pi//In Matlab Filter order = Filter Length - 1//In Scilab Filter order = Filter Length

clear;clc;close;

forder = 5; //Filter Length M = 5 cfreq = [0.125,0]; // For LPF and HPF only first value of cfreq selected as cutoff frequency // Here cutoff frequency Wc_norm = cfreq(1) = 0.125

[wft,wfm,fr]=wfir('hp',forder,cfreq,'re',0);wft; // Time domain filter coefficientswfm; // Frequency domain filter valuesfr; // Frequency sample points

a=gca();a.thickness = 3;a.foreground = 1;

plot(a,fr,wfm,'marker','.','markeredg','red','marker size',2)xtitle('Magnitude Response Vs Normalized Frequency','Normalized Frequency W ------>','Magnitude Response H(w)---->');xgrid(2);

//RESULT

//High pass filter coefficents//- 0.1591549 - 0.2250791 0.75 - 0.2250791 - 0.1591549 for cut off frequency 0.125//which is equivalent to %pi/4

58

Page 14: Design of FIR Filter

Figure 2: Corresponding to Program 2.

59

Page 15: Design of FIR Filter

Program 3: This program is same as that of program 1 and program 2. But the filter order is changed to M =31.

//To Design a Digital FIR filter//High Pass Filter with cutoff frequency Wc = pi/4//In Scilab Wc = Wc/2 = pi/8//Normalized cutoff frequency Wc_norm = Wc/pi//In Matlab Filter order = Filter Length - 1//In Scilab Filter order = Filter Length

clear;clc;close;

forder =31; //Filter Length M = 31 cfreq = [0.125,0]; // For LPF and HPF only first value of cfreq selected as cutoff frequency // Here cutoff frequency Wc_norm = cfreq(1) = 0.125

[wft,wfm,fr]=wfir('hp',forder,cfreq,'re',0);wft; // Time domain filter coefficientswfm; // Frequency domain filter valuesfr; // Frequency sample points

a=gca();a.thickness = 3;a.foreground = 1;

plot(a,fr,wfm,'marker','.','markeredg','red','marker size',2)xtitle('Magnitude Response Vs Normalized Frequency','Normalized Frequency W ------>','Magnitude Response H(w)---->');xgrid(2);

60

Page 16: Design of FIR Filter

Figure 3: Corresponding to program 3 output

61

Page 17: Design of FIR Filter

Program 4: To write programs to generate LPF FIR filter coefficients for the given specifications in Problem 1.

//To Design a Digital FIR filter//Low Pass Filter with cutoff frequency Wc = pi/4//In Scilab Wc = Wc/2 = pi/8//Normalized cutoff frequency Wc_norm = Wc/pi//In Matlab Filter order = Filter Length - 1//In Scilab Filter order = Filter Length

clear;clc;close;

forder =5; //Filter Length M = 5 cfreq = [0.125,0]; // For LPF and HPF only first value of cfreq selected as cutoff frequency // Here cutoff frequency Wc_norm = cfreq(1) = 0.125

[wft,wfm,fr]=wfir('lp',forder,cfreq,'re',0);wft; // Time domain filter coefficientswfm; // Frequency domain filter valuesfr; // Frequency sample points

a=gca();a.thickness = 3;a.foreground = 1;

plot(a,fr,wfm,'marker','.','markeredg','red','marker size',2)xtitle('Magnitude Response Vs Normalized Frequency','Normalized Frequency W ------>','Magnitude Response H(w)---->');xgrid(2);

//RESULT

//Low Pass Filter coefficients// 0.1591549 0.2250791 0.25 0.2250791 0.1591549 for cut off frequency 0.125//which is equivalent to %pi/4

62

Page 18: Design of FIR Filter

Figure 4: Corresponds to program 4 output. Filter Length M = 5

63

Page 19: Design of FIR Filter

Program 5: Same as that of Program 4 specifications with Filter order M = 31.

////To Design a Digital FIR filter//Low Pass Filter with cutoff frequency Wc = pi/4//In Scilab Wc = Wc/2 = pi/8//Normalized cutoff frequency Wc_norm = Wc/pi//In Matlab Filter order = Filter Length - 1//In Scilab Filter order = Filter Length

clear;clc;close;

forder = 31; //Filter Length M = 31 cfreq = [0.125,0]; // For LPF and HPF only first value of cfreq selected as cutoff frequency // Here cutoff frequency Wc_norm = cfreq(1) = 0.125

[wft,wfm,fr]=wfir('lp',forder,cfreq,'re',0);wft; // Time domain filter coefficientswfm; // Frequency domain filter valuesfr; // Frequency sample points

a=gca();a.thickness = 3;a.foreground = 1;

plot(a,fr,wfm,'marker','.','markeredg','red','marker size',2)xtitle('Magnitude Response Vs Normalized Frequency','Normalized Frequency W ------>','Magnitude Response H(w)---->');xgrid(2);

64

Page 20: Design of FIR Filter

Figure 5: Corresponding to program 4 output

65

Page 21: Design of FIR Filter

Program 6: To design and plot Low Pass Filter frequency response and High Pass Filter

//Frequency response on the same Graphic Window.//To Design a Digital FIR filter//Low Pass Filter with cutoff frequency Wc = pi/4//In Scilab Wc = Wc/2 = pi/8//Normalized cutoff frequency Wc_norm = Wc/pi//In Matlab Filter order = Filter Length - 1//In Scilab Filter order = Filter Length

clear;clc;close;

forder = 31; //Filter Length M = 31 cfreq = [0.125,0]; // For LPF and HPF only first value of cfreq selected as cutoff frequency // Here cutoff frequency Wc_norm = cfreq(1) = 0.125

//To generate Low Pass Filter Coefficients[wft_LPF,wfm_LPF,fr_LPF]=wfir('lp',forder,cfreq,'re',0);

//To generate High Pass Filter Coefficients[wft_HPF,wfm_HPF,fr_HPF]=wfir('hp',forder,cfreq,'re',0);

a=gca();a.thickness = 3;a.foreground = 1;

plot(a,fr_LPF,wfm_LPF,'marker','.','markeredg','red','marker size',2)plot(a,fr_HPF,wfm_HPF,'marker','*','markeredg','blue','marker size',2)xtitle('Magnitude Response Vs Normalized Frequency','Normalized Frequency W ------>','Magnitude Response H(w)---->');xgrid(1);h1 = legend('Low Pass Filter','High Pass Filter');

66

Page 22: Design of FIR Filter

Figure 6: Plotting LPF frequency response and HPF frequency response on the same Graphic window

67

Page 23: Design of FIR Filter

Problem 3

A Band Pass filter is to be designed with the following desired frequency response

Determine the filter coefficients hd(n) if the window function is defined as,

[ That is Rectangular Window]

M = filter length = 11.

Sol:

68

Page 24: Design of FIR Filter

h(0) = hd(0 )*w(0) = 0.5

h(1) = hd(1 )*w(1) = 0 = h (-1)

h(2) = hd(2 )*w(2) = - 0.3183 = h (-2)

h(3) = hd(3 )*w(3) = 0 = h(-3)

h(4) = hd(4 )*w(4) = 0 = h (-4)

h(5) = hd(5 )*w(5) = 0 = h (-5)

Note: In SciLab5 programming

h(n) = { 0, 0, 0, - 0.3183099, 0, 0.5, 0, - 0.3183099, 0, 0, 0}

69

Page 25: Design of FIR Filter

Problem 4

A Band Pass filter is to be designed with the following desired frequency response

Determine the filter coefficients hd(n) if the window function is defined as,

[ That is Rectangular Window]

M = filter length = 11.

Sol:

h(0) = hd(0 )*w(0) = 0.667

h(1) = hd(1 )*w(1) = 0 = h (-1)

h(2) = hd(2 )*w(2) = 0.2757 = h (-2)

h(3) = hd(3 )*w(3) = 0 = h(-3)

h(4) = hd(4 )*w(4) = -0.1378 = h (-4)

70

Page 26: Design of FIR Filter

h(5) = hd(5 )*w(5) = 0 = h (-5)

Note: In SciLab5 programming

h(n) = { 0, - 0.1378988, 0, 0.2755978, 0, 0.6668, 0, 0.2755978, 0, - 0.1378988, 0}

71

Page 27: Design of FIR Filter

Program 7:

//To Design a Digital FIR filter//Band Pass Filter with cutoff frequencies =[Wc1,Wc2] = [pi/4,3pi/4]//In Scilab [Wc1,Wc2] = [Wc1/2,Wc2/2] = [pi/8, 3pi/8]//Normalized cutoff frequency Wc_norm = [Wc1/pi,Wc2/pi] = [0.125,0.375]//In Matlab Filter order = Filter Length - 1//In Scilab Filter order = Filter Length

clear;clc;close;

forder = 11; //Filter Length M = 11 cfreq = [0.125,0.375]; // For LPF and HPF only first value of cfreq selected as cutoff frequency // Here cutoff frequency Wc_norm = cfreq(1) = 0.125

[wft,wfm,fr]=wfir('bp',forder,cfreq,'re',0);wft; // Time domain filter coefficientswfm; // Frequency domain filter valuesfr; // Frequency sample points

for i = 1:length(wft) if(abs(wft(i))< 1D-5) wft(i) = 0.0; endend

a=gca();a.thickness = 3;a.foreground = 1;

plot(a,fr,wfm,'marker','.','markeredg','red','marker size',2)xtitle('Frequency Response of Band Pass Filter with Lower cutoff =0.125 & Upper Cutoff = 0.375','Normalized Frequency W ------>','Magnitude Response H(w)---->');xgrid(2);

//RESULT

//Band Pass Filter coefficients

//wft =[0. 0. 0. - 0.3183099 0. 0.5 0. - 0.3183099 0. 0. 0.]

72

Page 28: Design of FIR Filter

Figure 7: Frequency response of Band Pass Filter

73

Page 29: Design of FIR Filter

Program 8: Design of Digital Band Stop Filter

//To Design a Digital FIR filter//Band Stop Filter with cutoff frequencies =[Wc1,Wc2] = [pi/3,2pi/3]//In Scilab [Wc1,Wc2] = [Wc1/2,Wc2/2] = [pi/6, 2pi/6//Normalized cutoff frequency Wc_norm = [Wc1/pi,Wc2/pi] = [1/6,2/6]=[0.1667,0.3333]//In Matlab Filter order = Filter Length - 1//In Scilab Filter order = Filter Length

clear;clc;close;

forder = 11; //Filter Length M = 11 cfreq = [0.1667,0.3333]; // For LPF and HPF only first value of cfreq selected as cutoff frequency // Here cutoff frequency Wc_norm = cfreq(1) = 0.125

[wft,wfm,fr]=wfir('sb',forder,cfreq,'re',0);wft; // Time domain filter coefficientswfm; // Frequency domain filter valuesfr; // Frequency sample points

for i = 1:length(wft) if(abs(wft(i))< 1D-5) wft(i) = 0.0; endend

a=gca();a.thickness = 3;a.foreground = 1;

plot(a,fr,wfm,'marker','.','markeredg','red','marker size',2)xtitle('Frequency Response of Band Stop Filter with Lower cutoff =0.1667 & Upper Cutoff = 0.3333','Normalized Frequency W ------>','Magnitude Response H(w)---->');xgrid(2);

//RESULT

//Band Stop Filter coefficients

//wft =[0. - 0.1378988 0. 0.2755978 0. 0.6668 0. 0.2755978 0. - 0.1378988 0]

74

Page 30: Design of FIR Filter

Figure 8: Frequency Response of Band Stop FIR Filter

75

Page 31: Design of FIR Filter

6.2 Design of FIR filters using Frequency Sampling Technique:

In the frequency sampling method the desired frequency response is specified at a set of equally spaced frequencies

If It is said to be Type 1 design

If It is said to be Type 2 design

A desired frequency response of the FIR filter is given by

G d ~^h

=G ~^h

= h(n)e- j~nn=0

m- 1

/ , where ‘m’ is the length of the filter

When

76

Page 32: Design of FIR Filter

Symmetric Frequency Samples:

Multiply by on both sides,

Note 1:

Since h(n) is real frequency samples satisfy the symmetric condition given by,

This symmetric condition along with symmetric conditions for h(n) can be used to

reduce the frequency specifications from ‘M’ points to points for ‘M’ odd and

points for ‘M’ even.

Symmetric (or) Asymmetric:

77

Page 33: Design of FIR Filter

Note 2:

The advantage of frequency sampling method is the efficient frequency sampling structure is obtained when most of the frequency samples are zero.

Assume,

Type 1 and Type 2 design for both h(n) is symmetric and asymmetric

Case (i) Type design, h (n) is symmetric :

78

Page 34: Design of FIR Filter

Case (ii) Type 2 design, h(n) is symmetric :

Case (iii) Type 1 design, h(n) is symmetric:

79

Page 35: Design of FIR Filter

Case (iv) Type 2 design, h(n) is asymmetric:

80

Page 36: Design of FIR Filter

Program 9: Design of LPF FIR filter using Frequency Sampling Technique

//Design of FIR Filter using Frquency Sampling Technique//Low Pass Filter Design//Cutoff Frequency Wc = pi/2//M = Filter Lenth = 7

clear;clc;M = 7;N = ((M-1)/2)+1wc = %pi/2;for k =1:M w(k) = ((2*%pi)/M)*(k-1); if (w(k)>=wc) k-1 break endendw

for i = 1:k-1 Hr(i) = 1; G(i) = ((-1)^(i-1))*Hr(i);end

for i = k:N Hr(i) = 0; G(i) = ((-1)^(i-1))*Hr(i);end

Gh = zeros(1,M);

G(1)/M;

for n = 1:M for k = 2:N h(n) = G(k)*cos((2*%pi/M)*(k-1)*((n-1)+(1/2)))+h(n); end h(n) = (1/M)* (G(1)+2*h(n));endhst1=fsfirlin(h,1);pas=1/prod(size(hst1))*.5;fg=pas:pas:.5;//normalized frequencies grida=gca();a.thickness = 3;a.foreground = 1;

81

Page 37: Design of FIR Filter

plot(a,2*fg,hst1,'marker','.','markeredg','red','marker size',2)xtitle('Frequency Response of LPF with Normalized cutoff =0.5','Normalized Frequency W ------>','Magnitude Response H(w)---->');xgrid(2);//plot2d(2*fg,hst1); //RESULT // N = 4. // ans = 2. // w = // 0. // 0.8975979 // 1.7951958 //G = // 1. // - 1. // 0. // 0. //ans = 0.1428571 //h = - 0.1145625 0. 0. 0. 0. 0. 0. //h = - 0.1145625 0.0792797 0. 0. 0. 0. 0. //h = - 0.1145625 0.0792797 0.3209971 0. 0. 0. 0. //h = - 0.1145625 0.0792797 0.3209971 0.4285714 0. 0. 0. //h = - 0.1145625 0.0792797 0.3209971 0.4285714 0.3209971 0. 0. //h = - 0.1145625 0.0792797 0.3209971 0.4285714 0.3209971 0.0792797 0. //h = - 0.1145625 0.0792797 0.3209971 0.4285714 0.3209971 0.0792797 - 0.1145625

82

Page 38: Design of FIR Filter

Figure.9 Digital LPF FIR Filter Design using Frequency Sampling Technique. With Cutoff Frequency = 0.5, Filter length = 7

83

Page 39: Design of FIR Filter

Program 10. Design of Digital BPF FIR Filter design using Frequency Sampling Technique

//Design of FIR Filter using Frquency Sampling Technique//Band Pass Filter Design//Cutoff Frequency Wc = pi/2//M = Filter Lenth = 31

clear;clc;M = 15;N = ((M-1)/2)+1wc = %pi/2;

Hr = [1,1,1,1,0.4,0,0,0];

for k =1:length(Hr) w(k) = ((2*%pi)/M)*(k-1);endwk = length(Hr);

for i = 1:k //Hr(i) = 1; G(i) = ((-1)^(i-1))*Hr(i);end

Gh = zeros(1,M);

for n = 1:M for k = 2:N h(n) = G(k)*cos((2*%pi/M)*(k-1)*((n-1)+(1/2)))+h(n); end h(n) = (1/M)* (G(1)+2*h(n));end h hst1=fsfirlin(h,1);pas=1/prod(size(hst1))*.5;fg=pas:pas:.5;//normalized frequencies grida=gca();a.thickness = 3;a.foreground = 1;

Maximum_Gain = max(hst1)

gain_3dB = Maximum_Gain/sqrt(2) plot(a,2*fg,hst1,'marker','.','markeredg','red','marker size',2)

84

Page 40: Design of FIR Filter

xtitle('FIR Filter design using Frequency Sampling Tech. Frequency Response of BPF','Normalized Frequency W ------>','Magnitude Response H(w)---->');xgrid(2);plot(2*fg,gain_3dB,'Magenta')plot(2*fg,Maximum_Gain,'cyan')h1 = legend('Frequency Response of BPF','3dB Gain','Maximum Gain');

//RESULT // N =// // 8. // w =// // 0. // 0.4188790 // 0.8377580 // 1.2566371 // 1.6755161 // 2.0943951 // 2.5132741 // 2.9321531 // G =// // 1. // - 1. // 1. // - 1. // 0.4 // 0. // 0. // 0. // h =// // // column 1 to 9// // - 0.0141289 - 0.0019453 0.04 0.0122345 - 0.0913880 - 0.0180899 0.3133176 0.52 0.3133176 // // column 10 to 15// // - 0.0180899 - 0.0913880 0.0122345 0.04 - 0.0019453 - 0.0141289 // Maximum_Gain =// // 0.52 // gain_3dB =// // 0.3676955

85

Page 41: Design of FIR Filter

Figure 10. Digital BPF FIR Filter Design using Frequency Sampling Technique. With Cutoff Frequencies =[0.4 0.5], Filter length = 15

86