PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

DTFT, DFT, ZT, and FFT 519


012345678

012345678

012345678
frequency W

frequency W

Phase of DFT[g(n)] versus W

Magnitude of DFT[g(n)] versus W

Linear convolution [g(n) = conv(f(n), h(n))] versus n

time index n

40

100

50

0

20

Amplitude

Magnitude

Angle in rad.

− 20

0

5

0

− 5

FIGURE 5.31
Plots of part a of g(n) and DFT[g(n)] by evaluating the linear convolution of Example 5.6.

ste m (n,g g n);h old o n; plo t(n,g g n); yla b e l(‘A m plitu d e’);
xlabel (‘time index n’)
title(‘ Circular convolution g(n)=ifft[DTF(f(n)*DTF(h(n)] vs. n’)
subplot (3,1,2)
DFT _ cir = fft(ggn,9);
stem(n,abs(DFT _ cir));hold on; plot(n,abs(DFT _ cir));
xlabel(‘frequency W’);
ylabel(‘Magnitude’);
title(‘Magnitude of DFT[g(n)] vs. W’)
subplot (3,1,3)
stem(n, angle(DFT _ cir));hold on; plot(n, angle(DFT _ cir));
xlabel(‘frequency W’);
title (‘Phase of DFT[g(n)] vs. W’);ylabel(‘Angle in rad.’)

figure(3)
error = gn-ggn;
bar(n,error); title(‘[Errors] vs. time index n’)
ylabel (‘Amplitude’)
xlabel (‘ time index n’)

The script fi le convolutions is executed and the results are indicated in Figures 5.31
through 5.33.
Free download pdf