%
% 2 masses 2 springs
%

close all
figure(1)

t = 0:.01:1;

sx = t;
sy = 0.6*sin(4*pi*t);

mx = cos(2*pi*t);
my = sin(2*pi*t);

lx = [0 1];
ly = [0 0];

wx = [0 0];
wy = [-2 2];

plot(wx,wy,'k','linewidth',1.5)
hold
text(1,2,'(A)','fontsize',20)
plot(lx,ly,'k','linewidth',1.5)
plot(sx+1,sy,'k','linewidth',1.5)
text(3/2,1.2,'k_1','fontsize',16)
plot(lx+2,ly,'k','linewidth',1.5)
plot(mx+4,my,'k','linewidth',1.5)
text(3.7,-.1,'m_1','fontsize',16)
plot([4 4],[1.2 1.8],'k','linewidth',1.5)
plot([4.1 4.5],[1.5 1.5],'k','linewidth',1.5)
plot([4.4 4.5],[1.6 1.5],'k','linewidth',1.5)
plot([4.4 4.5],[1.4 1.5],'k','linewidth',1.5)
text(4.6,1.5,'x_1','fontsize',16)
text(4.6,-1.5,'f_1','fontsize',16)
plot([4 4],[-1.2 -1.8],'k','linewidth',1.5)
plot([4.1 4.5],-[1.5 1.5],'k','linewidth',1.5)
plot([4.4 4.5],-[1.6 1.5],'k','linewidth',1.5)
plot([4.4 4.5],-[1.4 1.5],'k','linewidth',1.5)
plot(lx+5,ly,'k','linewidth',1.5)
plot(sx+6,sy,'k','linewidth',1.5)
text(6+1/2,1.2,'k_2','fontsize',16)
plot(lx+7,ly,'k','linewidth',1.5)
plot(mx+9,my,'k','linewidth',1.5)
text(8.7,-.1,'m_2','fontsize',16)
plot([9 9],[1.2 1.8],'k','linewidth',1.5)
text(9.6,1.5,'x_2','fontsize',16)
text(9.6,-1.5,'f_2','fontsize',16)
plot([9 9],[-1.2 -1.8],'k','linewidth',1.5)
plot([9.1 9.5],[1.5 1.5],'k','linewidth',1.5)
plot([9.4 9.5],[1.6 1.5],'k','linewidth',1.5)
plot([9.4 9.5],[1.4 1.5],'k','linewidth',1.5)
plot([9.1 9.5],-[1.5 1.5],'k','linewidth',1.5)
plot([9.4 9.5],-[1.6 1.5],'k','linewidth',1.5)
plot([9.4 9.5],-[1.4 1.5],'k','linewidth',1.5)

axis equal
axis off
hold

figure(2)
t = 0:.05:40;
sq3 = sqrt(3);
a = 2;  % a=1.01  and a=sq3+.01 for resonance
x1 = (sin(a*t)-a*sin(t))/(2*(a^2-1)) + ...
    (sin(a*t)-(a/sq3)*sin(sq3*t))/(2*(a^2-3));
x2 = (sin(a*t)-a*sin(t))/(2*(a^2-1)) - ...
    (sin(a*t)-(a/sq3)*sin(sq3*t))/(2*(a^2-3));
plot(t,-x1,'k','linewidth',1.5)
hold
plot(t,-x2,'k--','linewidth',1.5)
hold
xlabel('t','fontsize',14)
ylabel('x','fontsize',14)
text(1,1,'(B)','fontsize',20)
legend('x_1','x_2')
box off
hold off
