clear all
clf
set(0,'defaultaxesfontsize',20);
tmax=8;
t=-tmax:.01:tmax;
Nmax=40;
x=zeros(size(t));
for k=-Nmax:Nmax,
%periodic triangles in Ex. 3.7 
ck=-j*(-j)^k*2*sin(k*pi/2)/(k*pi)^2; Tp=4; c0=0.5;
%
%ramp in Fig. P3.22(a):
%ck=j*(-1)^k/(k*pi);  Tp=2; c0=0;
%
%periodic trapezoid in Fig P3.22(b):
%ck=6*(sin(k*pi/6)*sin(k*pi/2))/(k*pi)^2; Tp=6; c0=0.5;
%
%periodic triangles in Fig P3.22(c):
%ck=9*(1-exp(-j*2*pi*k/3))/(2*k*pi)^2; Tp=3; c0=1; 
%
%periodic rectangles in Fig P3.22(f):
%ck=j*(exp(-j*2*pi*k/3)+exp(-j*4*pi*k/3)-2)/(2*k*pi); Tp=3; c0=1;
%
if k==0, ck=0; end
 x=x+ck*exp(j*2*pi*k*t/Tp);
end
x=x+c0*ones(size(x));
plot(t,real(x),'linewidth',2)
hold on
plot([-tmax tmax],[0 0],'k','linewidth',2);
plot([0 0],[-1 2],'k','linewidth',2);
hold off




    
