clear all
clf
set(0,'defaultaxesfontsize',20);
Nmax=50;
t=-Nmax:Nmax;
N=16; Kn=3;
x=zeros(size(t));
ik=0;
for k=0:N-1,
    if k==0, ik=ik+1; 
        c(ik)=Kn/N; 
        %c(ik)=1/2; 
        %c(ik)=1;
        x=x+c(ik)*ones(size(x)); 
    else
 ik=ik+1;
    c(ik)=(sin(k*pi*Kn/N)/(N*sin(k*pi/N)))*(exp(-j*pi*k*(Kn-1)/N));
    %c(ik)=9*(1-exp(-j*2*k*pi/3))/(2*k*pi)^2;
    %c(ik)=j*(exp(-j*2*k*pi/3)+exp(-j*4*k*pi/3)-2)/(2*k*pi);
    %c(ik)=j*(-1)^k/(pi*k);
    %c(ik)=0.5*j*((sin((k+2+eps)*pi/2)/((k+2+eps)*pi))-(sin((k-2+eps)*pi/2)/((k-2+eps)*pi)));
    %c(ik)=sin(k*pi/2)/(k*pi);
 %
 x=x+c(ik)*exp(j*2*pi*k*t/N);
    end
end
%figure(1)
stem(t,real(x),'linewidth',2)
set(gca,'XTick',[-Nmax:2:Nmax])
axis([-Nmax Nmax -2 2]);
hold on
plot([-Nmax Nmax],[0 0],'k','linewidth',2);
plot([0 0],[-2 2],'k','linewidth',2);
hold off
%
%figure(2)
%stem(-Nmax:Nmax,abs(c),'linewidth',2)





    
