This example shows how to model the motion of a double pendulum using symbolic computation.
x - horizontal position of pendulum mass
y - vertical position of pendulum mass
θ - angle of pendulum (0 = vertical downwards, counter-clockwise is positive)
L - length of rod (constant)
We begin by defining symbols for θ1 and θ2.
We define displacement expressions for m1 and m2 and calculate velocity by differentiating displacement with respect to time.
We calculate acceleration by differentiating velocity with respect to time.
We will now evaluate the forces acting on the masses. We start by constructing a free body diagram of the forces on m1.
Balancing the horizontal and vertical force components results in 2 equations. Note that we use the acceleration expressions that we calculated previously (ax1 and ax2) in our equations.
We now evaluate the forces acting on m2. Our free body diagram shows that there are 2 forces acting on m2 ; tension from rod 2, and the force from the weight of the mass itself.
Balancing the horizontal and vertical force components results in 2 equations.
Our force evaluation produced a set of 4 equations with 4 unknowns ([θ1 θ2 T1 T2]). We will reduce our system to 2 equations with 2 unknowns by solving eq1 and eq2 for T1 and T2, and substituting the results into eq3 and eq4.
Before solving the system equations, we define the masses and rod lengths.
We specify initial conditions for mass position and angular velocity, and solve the final system equations (eq5, eq6) numerically using the numeric::odesolve2 function.
We animate the motion of the double pendulum. Note that this animation will not run in a Web browser, however you can download this example from MATLAB Central (http://www.mathworks.com/matlabcentral/) and run it yourself.