function windowing_time_circ_conv_freq_sinc(flag)
% flag = 0 [default] : sinc
% flag = 1           : cos(2 pi (1/4) n)

NFFT = 2^16;
freq = [0:NFFT-1]/NFFT - 0.5;

clf;

make_plot(10,0.25);

hui = uicontrol('style','slider','value',10,'min',1,'max',200,...
                'position',[10 10 300 20],'callback',{@nestfunc});

huj = uicontrol('style','slider','value',0.25,'min',0,'max',0.5,...
                'position',[400 10 300 20],'callback',{@nestfunc});

function make_plot(L,f0)
w = zeros(NFFT,1);
len = 2*L+1;
w(1:L+1) = 1/len;
w(end-L+1:end) = 1/len;
W = real(fftshift(fft(w)));

h = zeros(NFFT,1);
h(1:L+1) = (2*f0)*sinc((2*f0)*[0:L]);
h(end-L+1:end) = (2*f0)*sinc((2*f0)*[-L:-1]);
H = real(fftshift(fft(h)));

plot([-0.5 -f0 -f0 f0 f0 0.5],[0 0 1 1 0 0],'k','LineWidth',2);
hold on;
plot(freq,[H W],'LineWidth',2);
hold off;
grid on;
set(gca,'FontSize',14);
xlabel('Normalized Frequency [cycles/sample]','FontSize',14);
end

function nestfunc(src,evd)
L = round(get(hui,'Value'));
f0 = get(huj,'Value');
make_plot(L,f0);
end

end

