% pendulum.m % System of 2 DE's defining the pendulum % theta'' + (c/(mL))theta' + (g/L)sin(theta) % % Corresponding first order system is % % x(1)' = x(2) % x(2)' = -(c/(mL))x(2) - (g/L)sin(x(1)) % % m is the mass % L is the length of the pendulum % g is acceleration due to gravity % c is the damping constant % % function returns the right hand sides of the system function xprime = pendulum(t,x,m,L,g,c) xprime(1) = x(2); xprime(2) = -(c/(m*L))*x(2) - (g/L)*sin(x(1)); xprime = [xprime(1); xprime(2)];