NDFT = 2^8;
kDFT = [0:NDFT-1];
fDFT = kDFT/NDFT;

NDTFT = 2^14;
fDTFT = [0:NDTFT-1]/NDTFT;
kDTFT = fDTFT*NDFT;

f0 = 0.17;
x = 2*f0*sinc(2*f0*[-NDTFT/2:NDTFT/2-1]);
XDTFT = abs(fft(x,NDTFT));
XDTFT = XDTFT./max(abs(XDTFT));

L = 60;  % <= NDFT
w = ones(1,L)/L;
w = my_hann(L).';
%w = my_hamming(L).';
%w = my_triang(L).';
y = 2*f0*sinc(2*f0*[-L/2:L/2-1]);
y = y.*w;
YDTFT = abs(fft(y,NDTFT));
YDTFT = YDTFT./max(abs(YDTFT));
WDTFT = abs(fft(w,NDTFT));
WDTFT = WDTFT./max(abs(WDTFT));
YDFT = abs(fft(y,NDFT));
YDFT = YDFT./max(abs(YDFT));
WDFT = abs(fft(w,NDFT));
WDFT = WDFT./max(abs(WDFT));

subplot(311);
plot(fDTFT,[YDTFT; WDTFT; XDTFT]);
ylim([0 max(YDTFT)]);

subplot(312);
plot(kDTFT,[YDTFT; WDTFT]); hold on;
plot(kDFT,[YDFT;WDFT],'.'); hold off;
ylim([0 max(YDTFT)]);
xlim([0 NDFT]);

subplot(313);
plot(kDTFT,20*log10([YDTFT; WDTFT])); hold on;
plot(kDFT,20*log10([YDFT;WDFT]),'.'); hold off;
ylim([-50 max(20*log10(YDTFT))]);
xlim([0 NDFT]);
