% Example 4.4
% Computes the frequency spectra for the pulse train
c0 = 0.5;
w0 = pi;
n = -9:9;
magcn = [1/pi 0 1/pi/3 0 1/pi/5 0 1/pi/7 0 1/pi/9]; 
magcn = [magcn(9:-1:1) c0 magcn];   
angcn = [ 0    0 pi  0  0     0  pi 0 0];
angcn = [-angcn(9:-1:1) 0 angcn];
angcn = angcn*180/pi;      % converts to degrees
subplot(211),stem(n*w0,magcn);
title('Example 4.4')
xlabel('Frequency (rad/sec)')
ylabel('|c_n|')
text(pi*.6,.4,'1/p','FontName','symbol');
text(3*pi*.8,.2,'1/3p','FontName','symbol');
text(5*pi*.9,.14,'1/5p','FontName','symbol');
text(7*pi*.93,.12,'1/7p','FontName','symbol');
text(9*pi*.95,.1,'1/9p','FontName','symbol');
text(-pi*1.5,.4,'1/p','FontName','symbol');
text(-3*pi*1.2,.2,'1/3p','FontName','symbol');
text(-5*pi*1.12,.14,'1/5p','FontName','symbol');
text(-7*pi*1.07,.12,'1/7p','FontName','symbol');
text(-9*pi*1.05,.1,'1/9p','FontName','symbol');
subplot(212),stem(n*w0,angcn);
ylabel('Angle c_n')
xlabel('Frequency (rad/sec)')
subplot(111)
