%Demo done during Session 21 demonstrating
% DFT of finite length sinusoid
%L: length of sinusoid
%N: "length" of DFT = no. of equi-spaced
%   DTFT is evaluated (sampled) at
%   over 0 < omega < 2pi
clf
set(0,'defaultaxesfontsize',20);
omega1=linspace(-pi,pi,32);
omega2=linspace(-pi,pi,128);
%
x1=exp(j*2*pi*(5/32)*(0:31));
y1=abs(fftshift(fft(x1,32)));
plot(omega1,y1,'Linewidth',3)
axis([-pi pi 0 32])
title('Case of N=L, x[n]=exp(j2pik/L)'),...
xlabel('omega'), ylabel('Magnitude of DFT')
pause
z1=abs(fftshift(fft(x1,128)));
plot(omega2,z1,'Linewidth',3)
axis([-pi pi 0 32])
title('Case of N=4*L, x[n]=exp(j2pik/L)'),...
xlabel('omega'), ylabel('Magnitude of DFT')
pause
x2=exp(j*2*pi*(5.5/32)*(0:31));
y2=abs(fftshift(fft(x2,32)));
plot(omega1,y2,'Linewidth',3)
axis([-pi pi 0 32])
title('Case of N=L, x[n]=exp[j2pi(k+.5)/L]'),...
xlabel('omega'), ylabel('Magnitude of DFT')
pause
z2=abs(fftshift(fft(x2,128)));
plot(omega2,z2,'Linewidth',3)
axis([-pi pi 0 32])
title('Case of N=4*L and w=2pi(k+.5)/L'),...
xlabel('omega'), ylabel('Magnitude of DFT')
%
pause
%
x1=cos(2*pi*(5/32)*(0:31));
y1=abs(fftshift(fft(x1,32)));
plot(omega1,y1,'Linewidth',3)
axis([-pi pi 0 32])
title('Case of N=L, x[n]=cos(2pikn/L)'),...
xlabel('omega'), ylabel('Magnitude of DFT')
%
pause
z1=abs(fftshift(fftshift(fft(x1,128))));
plot(omega2,z1,'Linewidth',3)
axis([-pi pi 0 32])
title('Case of N=4*L, x[n]=cos(2pikn/L)'),...
xlabel('omega'), ylabel('Magnitude of DFT')
%
pause
x2=cos(2*pi*(5.5/32)*(0:31));
y2=abs(fftshift(fft(x2,32)));
plot(omega1,y2,'Linewidth',3)
axis([-pi pi 0 32])
title('Case of N=L, x[n]=cos[2pi(k+.5)n/L]'),...
xlabel('omega'), ylabel('Magnitude of DFT')
%
pause
z2=abs(fftshift(fft(x2,128)));
plot(omega2,z2,'Linewidth',3)
axis([-pi pi 0 32])
title('Case of N=4*L, x[n]=cos[2pi(k+.5)n/L]'),...
xlabel('omega'), ylabel('Magnitude of DFT')
%
