This code simulates and animates a simple pendulum using both linear and nonlinear dynamic models. A larger difference is observed between linear and nonlinear models when maximum angular position is large. This condition can be achieved by specifying either a large initial angle or velocity.
After simulation of both the linear and nonlinear models the code steps through each time step and plots the pendulum as well as its position and velocity trajectories. These plots are recorded using the getframe command, and then used to produce a video of the animation using both the movie2avi and VideoWriter commands.
Start from AnimatePendulum.m file, after pressing run, animated figure will run for 12 sec. Pendulum hight and velocity will be ploted and animated also as the pendulm itself moves.