File Exchange

image thumbnail

Animated Double Pendulum

version (114 KB) by Alexander Erlich
Show animation of the double pendulum's (mostly) chaotic behavior.


Updated 04 Oct 2010

View Version History

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

For animation, the program uses Matlab's normal plot command combined with the drawnow command. It is based on the ode45 solution of the corresponding differential equations.

Comprehensive documentation is provided, including a sketch of the most important steps of how to derive the equations of motion. A simple Mathematica notebook contains all of the manipulations.

Start the program via >> double_pendulum_init

You can adapt parameters such as rod lengths, masses and initial angular positions and velocities in the double_pendulum_init.m file.

It might be interesting to implement some features in future versions, such as angular time dependence plots, phase space portraits or Poincaré sections.

Have fun observing the rich dynamic behaviour of this simple, but mostly chaotic system :-)

Cite As

Alexander Erlich (2021). Animated Double Pendulum (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (16)

Seojun Lee

Elvira Martikainen

Sam Gregg

Does not run.

Igor Khovanov

To Liu. Yes, you are right, the built-in Matlab ODE solvers do not conserved the energy in Hamiltonian systems. You need to use a different solver, for example based on the Verlet method

Yifan Liu

Does anyone know why this simulation fails at a larger time than 100 seconds(1000 seconds for example)? It seems that the total energy is not conserved. could it be a Matlab problem given the Lagrange forms are correct?

Yifan Liu

Hugo Osorio

Viggo Wivestad

Very nice illustration. I am curious however to why the pendulum starts to move when initializing it at it's upward equilibrium
(phi1 = pi;dtphi1 = 0;phi2 = pi;dtphi2 = 0;)
Is this due to approximation mistakes by matlab where the number pi is represented with a finite number of decimals?

nitish kumar vaja

amazing, this program could be a base reference for further works.


Results are very inconsistent with other projects and online simulators, but they seem to use iterative calculations and not ivp deq's. Also equations in m-file are inconsistent with pdf documentation. Can you please elaborate on that?






Michu Gura


MATLAB Release Compatibility
Created with R2007a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: SimplePendulum

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!