clear all
clf
set(0,'defaultaxesfontsize',20);
t=-7.99:.01:7.99;
Nmax=30;
x=zeros(size(t));
ik=0;
for k=-Nmax:Nmax,
    if k==0, ik=ik+1; c(ik)=0;
        %x=x+(1/2)*ones(size(x)); ik=ik+1; c(ik)=1/2;
    else
 %   ck=-3*(sin(k*pi/3))^2/(k*pi)^2;
 ik=ik+1;
    c(ik)=(1-(-1)^k)*6*(sin(k*pi/2)*sin(k*pi/6))/(k*pi)^2;
 %
 x=x+c(ik)*exp(j*2*pi*k*t/6);
    end
end
figure(1)
plot(t,real(x),'linewidth',2)
set(gca,'XTick',[-8:8])
axis([-8 8 -2 2]);
hold on
plot([-8 8],[0 0],'k','linewidth',2);
plot([0 0],[-2 2],'k','linewidth',2);
hold off
%
figure(2)
stem(-Nmax:Nmax,abs(c),'linewidth',2)





    
