PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

DTFT, DFT, ZT, and FFT 509


stem (nn,f1nn)
ylabel (‘Amplitude of f1(n)’);xlabel (‘time index n’);
title(‘f1(n) vs. n’)
axis ([-4 10 0 1.1])
subplot (2,1,2)
f2nn =[zeros(1,4) f2];
stem(nn,f2nn)
title(‘f2(n) vs. n’)
ylabel (‘Amplitude of f2(n)’);
xlabel (‘time index n’); axis([-4 10 0 1.1])
W=linspace(-pi,pi,100);
DTFT _ f1=1./(1-0.3*exp(-j.*W));
DTFT _ f2=1./(1-0.9*exp(-j.*W));

figure(2)
subplot (2,1,1)
plot (W,abs(DTFT _ f1));title(‘ DTFT[f1(n)]=1./(1-0.3*exp(-j.*W))’);
xlabel (‘frequency W ’), ylabel(‘Magnitude’)
subplot (2,1,2)
plot (W,angle(DTFT _ f1));
xlabel (‘frequency W’), ylabel(‘Phase angle in rad.’)

figure(3)
subplot (2,1,1)
plot (W,abs(DTFT _ f2));title(‘ DTFT[f2(n)]=1./(1-0.9*exp(-j.*W))’);
xlabel(‘frequency W ’), ylabel(‘Magnitude’)
subplot(2,1,2)
plot (W,angle(DTFT _ f2));
xlabel (‘frequency W ’), ylabel(‘Phase angle in rad.’)

figure(4)
subplot (2,1,1)
plot (W,real(DTFT _ f1));title(‘ real [DTFT[f1(n)] vs. W’);
ylabel (‘Amplitude’)
subplot (2,1,2)
plot (W,imag(DTFT _ f1));title(‘ imag [DTFT[f1(n)] vs. W’);
xlabel (‘frequency W ’), ylabel(‘Amplitude’)

figure(5)
f12 = 2*f1nn+3*f2nn;
DTFT _ 12 = 2*DTFT _ f1+3*DTFT _ f2;
subplot (3,1,1)
stem(nn,f12);
ylabel (‘Amplitude’)
title (‘[2f1(n)+3f2(n)] vs. time index n’)
subplot (3,1,2)
plot (W,abs(DTFT _ 12)), title(‘abs[DTFT(2f1(n)+3f2(n))] vs. W’);
ylabel (‘Magnitude’)
subplot (3,1,3)
plot (W,angle(DTFT _ 12));title(‘angle[DTFT(2f1(n)+3f2(n))] vs. W’);
ylabel (‘ Phase in rad.’);
xlabel (‘ frequency W’)
Free download pdf