PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

638 Practical MATLAB® Applications for Engineers


aa = a(1:7)’;
[nn aa]
disp(‘*********************’)
m = 0:1:mid;
w = -pi:.01*pi:pi;
subplot(2,2,1)
stem(n,h)
axis([0 15 -6 5])
xlabel(‘time index n’)
ylabel(‘Amplitude ‘)
title(‘[Impulse sequence h(n)] vs. n’)
subplot(2,2,2)
stem(0:mid,a)
xlabel(‘ index n’)
ylabel(‘Amplitude’)
title(‘[coeff. a1(n)] vs. n’)
H1 = a(1)+a(2)*cos(w)+a(3)*cos(2*w)+a(4)*cos(3*w)+a(5)*cos(4*w);
H2 = a(6)*cos(5*w)+a(7)*cos(6*w);
H = H1+H2;
subplot(2,2,3)
plot(w,H)
xlabel(‘W‘);ylabel(‘Amplitude’)
title(‘H1(W) vs. W’)
subplot(2,2,4)
zplane(h,1)
title(‘zero-pole plot’)
The script fi le Fir_typ1_1 is executed and the results are shown as follows:
>> Fir _ typ1 _ 1

****coeff. of H1(w)****
index n coeff. a(n)
ans =
0 3
1 -2
2 4
3 8
4 6
5 4
6 -10
**********************

Example 6.14

Create the script fi le fi lter_wind that returns the normalized LP-FIR fi lters using the
command fi r1 in conjunction with the following windows:
a. Kaiser (β = 3.5)
b. Hanning
c. Blackman
d. Hamming
e. Tr i a ng u l a r
f. Bartlett
The fi lter’s specs are N = 64 and Rp = 1.4 dB.
Free download pdf