% A simple example of the sum 
% of different sines functions.

t=-2.*pi:0.01:2.*pi;
a=-0.4.*sin(5.*t);
b=0.3.*sin(2.*t);
c=sin(t);
d=sin(t./2);

plot(a,'b');
axis([0 1250 -1 1]);
title('f(1)=-0.4.*sin(5.*t)')

disp('Press any key to continue')
pause

plot(b,'b');
axis([0 1250 -1 1]);
title('f(2)=0.3.*sin(2.*t)')

disp('Press any key to continue')
pause

plot(c,'b');
axis([0 1250 -2 2]);
title('f(3)=sin(t)');

disp('Press any key to continue')
pause

plot(d,'b');
axis([0 1250 -2 2]);
title('f(3)=sin(t)');

s=a+b+c;
plot(s,'b');
axis([0 1250 -2 2]);
title('Sum of functions: f(1)+f(2)+f(3)');

disp('Press any key to continue')
pause

subplot(511);
plot(a,'b');
axis([0 1250 -1 1]);
axis('off');
text(-190,0,'-0.4 sin(5t)');
title('Fourier Series');

subplot(512);
plot(b,'b');
axis([0 1250 -1 1]);
axis('off');
text(-190,0,'0.3 sin(3t)');

subplot(513);
plot(c,'b');
axis([0 1250 -1 1]);
axis('off');
text(-190,0,'sin(t)');

subplot(514);
plot(d,'b');
axis([0 1250 -1 1]);
axis('off');
text(-190,0,'sin(t/2)');

subplot(515);
plot(s,'b');
axis([0 1250 -1.5 1.5]);
axis('off');
text(-190,0,'Sum');

%"Complex and Chaotic Nonlinear Dynamics. 
% Advances in Economics and Finance, 
% Mathematics and Statistics" 
% T.Vialar, Springer 2009.
% Copyright(c)