% solve the equation of motion of damped pendulum

global mass; global length; global grav; global viscous;
mass = 0.01; length = 2.0; grav = 9.8; viscous = 0.01;

interval = [0, 10];
qinit = [pi/3; 0]; % [ theta(0); omega(0) ]
[time, q] = ode45(@damped_pendulum, interval, qinit);

plot(time, q(:,1));
saveas(gcf, 'damped_pendulum_theta.png');

plot(time, q(:,2));
saveas(gcf, 'damped_pendulum_omega.png');

plot(q(:,1), q(:,2));
saveas(gcf, 'damped_pendulum_phase.png');
