% harmonic oscillations 

w = input('frequencies [w_1; w_2]: ');
if length(w) < 2
   w = [4; 5];
end;

echo on; 

% u(k,:) = cos(2*pi*w(k)*t)
t = linspace(0,1,1000);
u=cos(2*pi*w*t);

% superposition of harmonics
subplot(2,1,1); 
plot(t,u(1,:),'b-', t,u(2,:),'g-');
title(sprintf('frequencies: %7.3f, %7.3f', w));

subplot(2,1,2); 
plot(t,sum(u,1)); 
pause; 

% harmonics as coordinate functions
clf; 
plot(u(1,:),u(2,:));
title('Lissajous Figure');
axis square;
pause; 

echo off;

