% Calculate summation of cosines to illustrate synthesis
% of wavelet (signal) and analysis of signal (frequency 
% content).
% CosineSummation.m  L. Braile 03/25/06
dt = 0.002;
t = [-0.5:dt:0.5];
for i = 1:32
    f = i;
    X(i,:) = cos(2*pi*f*t);
end
x = sum(X);
figure
plot(t,x/4,'r-','linewidth',2)
hold on
for i = 1:32
    plot(t,X(i,:)+2*i,'b-')
end
hold off
axis([-0.5 0.5 -5 66]);
set(gca,'fontsize',14,'linewidth',2)
xlabel('Time (s)','fontsize',14)
ylabel('1 Hz to 32 Hz Cosines','fontsize',14)
title('Summation of Cosines to Generate Wavelet','fontsize',14)
text(-0.42,-3,'Wavelet (summation; bold line) scaled by 0.25','fontsize',14)