File Exchange

image thumbnail


version 1.1.1 (3.91 KB) by Aryeh Laks
Simulation of projectile motion using orbital mechanics. Note: must also be used with earth_moon_orbit_ode45.


Updated 06 Jun 2019

View License

Note: should be used with earth_moon_orbit_ode45 at

Depicts the path in 3 dimensions of a projectile being affected by the gravity of the Earth and the Moon using the Classical 4th Order Runge-Kutta Method and Euler's Method and how it compares to Matlab's built-in function, ode45.

See also for a PowerPoint presentation that explains the math behind the Orbital Simulation

Cite As

Aryeh Laks (2019). earth_moon_orbit_va​riable_timesteps (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (1)

Aryeh Laks

This program is dedicated to Professor Mark Edelen, who taught me Matlab & Numerical Methods at Howard Community College. He created a program similar to this that similated Apollo 13's flight path which inspired this program, and believed in my ability to create such a program.



Gives an option not to download earth_moon_orbit_ode45. Graphics updated. More comments added. Other small changes made


The program now uses the 4th Order Runge-Kutta Method as its main method. The if-structure was discarded in favor of using a constant divided by the changing velocity to create the changing time-step. ode45 was added in. Graphics were updated


This version is in 3D. The circles representing the Earth and the Moon were replaced by spheres. Certain variables were pulled out of loop and were created separately. A math mistake in calculating the displacement was discovered and fixed.

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

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor