clear all
close all

N = 5;
n = -2:2;
n_long = -10:10;
nu = linspace(-2,2,500);

x = [1 1 1 1 1];
x_long = [zeros(1,8) x zeros(1,8)];
X_DFT = fft(x);
X_TDFT = x*exp(-j*2*pi*n'*nu);

figure(1),pause

%%%%%%%%%%
% Plotta
%%%%%%%%%%
subplot(211)
h = stem(n_long,x_long);
set(h,'LineWidth',2,'MarkerSize',10)
set(gca,'FontSize',16)
title('x[n]','FontSize',16)
xlabel('n','FontSize',16)

subplot(212)
fill([-0.5 -0.5 0.5 0.5],[-2 6 6 -2],0.9*[1 1 1])
hold on
plot(nu,real(X_TDFT),[-2 2],[0 0],'k:','LineWidth',2)
hold off
set(gca,'FontSize',16)
axis([-2 2 -2 6])
title('X_d(\nu)','FontSize',16)
xlabel('\nu','FontSize',16)

pause

hold on
plot((0:4)/5,X_DFT,'ro','LineWidth',2,'MarkerSize',10)
hold off

pause,figure(2),pause

n = -12:12;
nu = linspace(-1,1,500);
x = cos(2*pi/8*n);
X_TDFT = x*exp(-j*2*pi*n'*nu);

subplot(211)
h = stem(n,x);
set(h,'LineWidth',2,'MarkerSize',10)
set(gca,'FontSize',16)
title('x[n]','FontSize',16)
xlabel('n','FontSize',16)
axis([-13 13 -1 1])

pause

subplot(212)
fill([-0.5 -0.5 0.5 0.5],[-5 15 15 -5],0.9*[1 1 1])
hold on
plot(nu,real(X_TDFT),[-2 2],[0 0],'k:','LineWidth',2)
hold off
set(gca,'FontSize',16)
axis([-1 1 -5 15])
title('X_d(\nu)','FontSize',16)
xlabel('\nu','FontSize',16)

pause
hold on
plot([-1 -1]/8,[-5 15],'r--',[1 1]/8,[-5 15],'r--','LineWidth',2)
hold off
