File Exchange

image thumbnail

A MATLAB Script for Predicting Solar Eclipses

version (645 KB) by David Eagle
Predict local circumstances of solar eclipses.


Updated 02 Apr 2019

View Version History

View License

PDF document and a MATLAB script named seclipse.m that can be used to predict local circumstances of solar eclipses. This computer program provides the universal times and topocentric coordinates of the Sun and Moon at the beginning and end of the penumbra contacts, and the time and coordinates at maximum eclipse. The source ephemeris for this routine is a JPL binary ephemeris file. This application uses several functions ported to MATLAB from the Fortran version of the NOVAS (Naval Observatory Vector Astrometry Subroutines) source code developed at the United States Naval Observatory ( JPL binary ephemeris files for Windows compatible computers can be downloaded at

Cite As

David Eagle (2021). A MATLAB Script for Predicting Solar Eclipses (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)


Screenshot to confirm Matlab code mistake


Please, be minded that the greatest eclipse conditions (only those) seem wrong. Below my test for Boise (Idaho) location, the time
attended of the event is 11:27 local time (=18:27 UTC), not 11:00 (=18:00 UTC). The discrepancy is high. Furthermore, the magnitude should be 0.993.
Best regards

local circumstances of solar eclipses
please input the calendar date
(1 <= month <= 12, 1 <= day <= 31, year = all digits!)
? 8,21,2017
please input the search duration (days)
? 30
please input the geographic latitude of the observer
(-90 <= degrees <= +90, 0 <= minutes <= 60, 0 <= seconds <= 60)
(north latitude is positive, south latitude is negative)
? 43,37,8
please input the geographic longitude of the observer
(0 <= degrees <= 360, 0 <= minutes <= 60, 0 <= seconds <= 60)
(east longitude is positive, west longitude is negative)
? -116,12,54
please input the altitude of the observer (meters)
(positive above sea level, negative below sea level)
? 834

searching for solar eclipse ...

greatest eclipse conditions
calendar date 21-Aug-2017
UTC time 18:00:00.001 ????
UTC Julian date 2457987.2500

MATLAB Release Compatibility
Created with R2018a
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!