PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

Analog and Digital Filters 637


Example 6.13

Given the following impulse response sequence: hn = [−5 2 3 4 2 −1 3 −1 2 4 3 2 −5] that
corresponds to a digital fi lter.
Determine the following:
a. The type of fi lter
b. By hand calculate its frequency response
c. Create the script fi le Fir_typ1_1 that returns the following plots:
i. h(n) versus n
ii. The fi rst seven a(n)’s terms of H(W), in a tablelike format, and verify the results
obtained in part (b)
iii. H(W) versus W
iv. Zero–pole

ANALYTICAL Solution
Clearly, h(n) = h(N − 1 − n) is a symmetric sequence with N = odd (13), then the fi lter is
an FIR type 1. Then from R.6.120

HW an nW
n

11
0

6
() ()cos( )



where
a 1 ( 0 ) = h( 6 ) = 3

a 1 ( 1 ) = 2 h( 6 − 1 ) + 2 h( 5 ) = 2 (− 1 ) = − 2

a 1 ( 2 ) = 2 h( 6 − 2 ) = 2 h( 4 ) = 2 ( 2 ) = 4

a 1 (3) = 2 h( 6 − 3 ) = 2 h( 3 ) = 2 ( 4 ) = 8

a 1 ( 4 ) = 2 h( 6 − 4 ) = 2 h( 2 ) = 2 ( 3 ) = 6

a 1 ( 5 ) = 2 h( 6 − 5 ) = 2 h( 1 ) = 2 ( 2 ) = 4

a 1 ( 6 ) = 2 h( 6 − 6 ) = 2 h( 0 ) = 2 (− 5 )

a 1 ( 6 ) = − 10
Then
H 1 (w) = a 1 ( 0 ) + a 1 ( 1 ) cos(W) + a 1 ( 2 ) cos( 2 W) + a 1 ( 3 )cos( 3 W)
+ a 1 ( 4 )cos( 4 W) + a 1 ( 5 )cos( 5 W) + a 1 ( 6 )cos( 6 W)
H 1 (ω) = 3 − 2 cos(W) + 4 cos( 2 W) + 8 cos( 3 W) + 6 cos( 4 W) + 4 cos( 5 W) − 10 cos( 6 W)

MATLAB Solution
% Script file : Fir _ typ1 _ 1
h = [-5 2 3 4 2 -1 3 -1 2 4 3 2 -5];
N = length(h);
n = 0:N-1;
mid = (N-1)/2;
disp(‘****coeff. of H1(w)****’)
disp(‘index n coeff. a(n)‘)
a = [h(mid+1) 2*h(mid:-1:1)]; % generates the a’s coeff.
nn = (0:6)’;
Free download pdf