PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

DTFT, DFT, ZT, and FFT 527


subplot (3,1,2)
stem(n,abs(DFT _ f2));hold on; stairs(n,abs(DFT _ f2));
ylabel(‘abs [ DFT[f2(n)]]’);
subplot (3,1,3)
stem (n, abs(DFT _ f3));hold on;stairs(n,abs(DFT _ f3));
xlabel (‘frequency W in rad.’);ylabel(‘abs [ DFT[f3(n)]]’)

figure(3) % phases of the DFT’s of the discrete
sequences
subplot(3,1,1)
stem (n,angle(DFT _ f1));hold on; stairs (n,angle(DFT _ f1));
ylabel (‘angle [ DFT[f1(n)]]’);
title (‘[Phases of the DFTs of f1(n), f2(n) & f3(n)] vs. W’)
subplot (3,1,2)
stem(n,angle(DFT _ f2)); hold on; stairs (n,angle(DFT _ f2));
ylabel(‘angle [ DFT[f2(n)]]’);
subplot (3,1,3)
stem (n, angle(DFT _ f3));hold on;stairs(n,angle(DFT _ f3));
xlabel (‘frequency W in rad.’); ylabel(‘angle[ DFT[f3(n)]]’);

figure(4) % magnitude and phase of the sum of DFTs
DFT _ fn = DFT _ f1+ DFT _ f2 + DFT _ f3;
DFTfn = fft(fn,16);
Subplot (2,1,1)
stem (n,abs(DFT _ fn)); hold on; stairs(n,abs(DFT _ fn));
ylabel (‘abs [ DFT[f(n)] ]’);xlabel(‘frequency W in rad.’);
title(‘ DFT[f1(n)] + DFT[f2(n)] + DFT[f3(n)] vs. W’)
subplot (2,1,2)
stem (n,angle(DFT _ fn));hold on; stairs (n,angle(DFT _ fn));
xlabel (‘frequency W in rad.’); ylabel (‘angle [ DFT[fn(n)] ]’);

figure(5) % error analysis in time and frequency
IDFT = ifft(DFT _ fn);
error _ time = fn-IDFT;
error _ mag _ DFT = abs(DFTfn)-abs(DFT _ fn);
error _ phase _ DFT = angle(DFTfn)-angle(DFT _ fn);
subplot(3,1,1)
bar (n, error _ time);
title (‘ Error analysis in time and frequency ‘)
ylabel(‘Amplitude in time’)
subplot (3,1,2)
bar (n,error _ mag _ DFT);
ylabel (‘[abs(DFTs)]’);
subplot(3,1,3)
bar (n,error _ phase _ DFT)
ylabel (‘ [angle(DFTs)]’)
xlabel (‘frequency W in rad.’);

The script fi le linearity is executed, and the results are shown in Figures 5.39 through 5.43.
Free download pdf