File Exchange Pick of the Week

Our best user submissions

Sunrise Sunset

Will's pick this week is Sunrise Sunset by Meysam Mahooti.

Ever wonder when the sun is going to set for an event you're planning in the future? Ever wonder when the moon is going to appear above the horizon in the year 2037? Well if so, this is the exchange contribution for you. Meysam predicts the altitude of the sun and moon for a particular point on the Earth's surface. Given a user-supplied date, the code identifies the time of day for sunrise, sunset, dawn, dusk, moon rise and moon set. Here is my the output for yesterday in my home of Columbia, Maryland.

Sunset/Sunrise predictions


How accurate is the algorithm? It must be pretty good because I found the answer to only be off by a minute for sunrise and sunset when I compared to a weather website. But how will it fare for a future prediction? That depends on the quality of the estimate of the sun and moon's position. The subroutines, SunPos.m and MoonPos.m include perturbation effects of other gravitational bodies, which would be essential for the estimates to remain accurate over a wide range of dates. I had the code estimate times six months from now; sunrise was the same time as the weather site, and sunrise was off by 3 minutes. Not too bad.

A couple things would make this contribution even stronger. First, I would make the main file a function rather than a script so that users can supply different arguments more easily. Second, I'd add more documentation to SunPos and MoonPos so that we could have better insight into the calculations. But still a great contribution...fun and easy to operate.

Comments
Let us know what you think here or leave a comment for Meysam.

|
  • print

댓글

댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.