
clear all;

%Un-Damped oscillation y''+b*y'+4y=0 with b=0
%Equivalently the 1st order linear system y'=v, v'=-4y-b*v
figure(1);
b=0;c=1.8;
[y,v]=meshgrid(-5:0.5:5,-5:0.5:5);
yp=v;vp=-4*y-b*v;
quiver(y,v,yp,vp);
axis tight;
hold on;

% Beats

F=@(t,z)[z(2);-4*z(1)-b*z(2)+cos(1.8*t)];
[t,z]=ode45(F,[0 100],[0;0]);
plot(z(:,1), z(:,2),'LineWidth',2);
hold off;

figure(2);
plot(t, z(:,1),'r','LineWidth',2);
%hold on
%plot(t, z(:,2),'b','LineWidth',2);
hold off;


