Double Compound Pendulum Simulation and Testing

For one of my mechanical engineering courses at RIT, I programmed a simulation of a double compound pendulum. I used the Lagrangian approach which was a nice dynamics refresher. I did the majority of the math and programming between 10pm and 4am one night but it took a few more days to figure out some of the bugs in the MATLAB code.

2 seconds of the simulated pendulum swinging

I looked through some references online for help with the Lagrangian approach for the double pendulum. One of the more difficult parts of this specific assignment is that there's a lot of documentation for double pendulums, but not much for double compound pendulums (the mass of the rods is used rather than point masses). 


I built a real double pendulum in class with my groupmates and we used image tracking to capture the x y positions of the beams to compare them to the simulation. We were somewhat close:


Below are the hand calculations for the double pendulum. A warning to anyone trying to recreate this, it's likely not completely right, I caught at least one sign error a week after writing the original code and there are probably more. There are likely other little errors that contribute to the error we saw between our simulation and real life.