Planets Rise/Set

Computation of rising and setting times of major planets, the Sun, and the Moon utilizing the iterative method


Updated Thu, 03 Nov 2022 09:36:20 +0000

View License

The test_Planets_RiseSet.m computes planetary positions using JPL_Eph_DE440.m. To compute the rising and setting times of a planet we first determine its geocentric equatorial coordinates (α and δ) for an arbitrary time on the given day. Then, from the declination and the geographical latitude, test_Planrise.m determines whether the planet is continuously above or below the horizon.
Year, month, day, lambda (Geographic east longitude of the observer in [deg]), phi (Geographic latitude of the observer in [deg]), and zone (local time - universal time in [hour]) are received, then rising and setting times of major planets, the Sun, and the Moon are computed.
east longitude and latitude of the observer can be found in:
local time - universal time is available here (daylight saving time is considered):
Montenbruck O., and Pfleger T., "Astronomy on the Personal Computer," Springer Verlag, Heidelberg, 4th edition, 2000.

Cite As

Meysam Mahooti (2023). Planets Rise/Set (, MATLAB Central File Exchange. Retrieved .

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

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes

JPL DE430 was replaced by JPL DE440, and test_Planets_RiseSet.m was modified.

The DE430 full matrix is added.

Accuracy is improved using planetary positions with respect to true equator and equinox of date rather than mean equator and equinox of date. (TOD_PlanPos = Nutation*Precession*ICRF_PlanPos)
Planetary positions are computed applying Jet Propulsion Laboratory Development Ephemeris (DE430). CityName.m is added to give the name of city you have entered its geographical latitude and longitude.
Condition for computation of Moon's rising/setting times is added.
line 30 of Planrise.m:
Sin_h0m = sin(pi/180*(7.5/60)); % sin(+7.5'); altitude for the Moon.