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

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

f0 = 0.37;
f0 = floor(f0*NDTFT)/NDTFT;
x = exp(1j*2*pi*f0*[0:NDTFT-1]);
f1 = 0.38;
f1 = floor(f1*NDTFT)/NDTFT;
x = x + exp(1j*2*pi*f1*[0:NDTFT-1]);
XDTFT = abs(fft(x,NDTFT));


L = 30;  % <= NDFT
w = ones(1,L);
%w = my_triang(L).';
%w = my_hamming(L).';
%w = my_hann(L).';
y = x(1:L).*w;
YDTFT = abs(fft(y,NDTFT));
WDTFT = abs(fft(w,NDTFT));
YDFT = abs(fft(y,NDFT));
WDFT = abs(fft(w,NDFT));

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]);
