View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Vectorized Solar Azimuth and Elevation Estimation

Join the 15-year community celebration.

Play games and win prizes!

» Learn more

4.4 | 5 ratings Rate this file 52 Downloads (last 30 days) File Size: 3.58 KB File ID: #23051 Version: 1.1
image thumbnail

Vectorized Solar Azimuth and Elevation Estimation


Darin Koblick (view profile)


20 Feb 2009 (Updated )

Predict the topocentric solar position defined by geodetic lat, lon, Alt, and a universal time

| Watch this File

File Information

Predict the azimuth and elevation of the Sun within +/- 1 degree at any geodetic latitude, longitude and altitude. Due to popular demand, this routine has been vectorized for speed.

Function Call: [Az El] = SolarAzEl('2008/02/18 13:10:00',60,15,0)

Input List:
UTC Date and Time - Use format YYYY/MM/DD hh:mm:ss or MATLAB date vector dimensions can be [N x 1]
Latitude - Site Latitude in degrees -90:90 -> S(-) N(+) dimensions can be [N x 1]
Longitude - Site Longitude in degrees -180:180 W(-) E(+) dimensions can be [N x 1]
Altitude - Site Altitude in km dimensions can be [N x 1]
Output List:
Az - Solar Azimuth angle in degrees [N x 1]
El - Solar Elevation/Altitude Angle in degrees [N x 1]


This file inspired Right Ascension/Declination To Azimuth/Elevation, Sun Moon Astronomical Data To Plan Orientation Research, and Spot Solar Panel Orientation Toolbox.

MATLAB release MATLAB 7.7 (R2008b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (6)
27 Jun 2016 Tunahan Liman

I need a code something like that. How can I get the codes?

Comment only
12 May 2016 Chad Greene

Chad Greene (view profile)

Superb. This function is well written and well documented. Thanks for sharing!

19 Feb 2015 L. He

L. He (view profile)

very nice program. I compare it with

the result is almost same. That one is more accurate,but not Vectorized yet.

Note: please change this line
jd = juliandate(datestr([y,mo,d,h,mi,s],'yyyy/mm/dd HH:MM:SS'),'yyyy/mm/dd HH:MM:SS');
do not use datestr but use date_num directly.
this will boost the speed, a lot

08 Apr 2013 Per

Per (view profile)

Very useful function. With a few updates it can handle vector time input. I would prefer the use of matlab UTC time input in order to speed up.

27 Aug 2009 Phil

Phil (view profile)

Ropey when using vector times: (line 36 generates a vector eccentricity: line 42 then requires an edit to force array multiply not matrix multiply). Still unable to get vector time version to agree with loop version....
As Mr. Picky, I would prefer time argin to be Matlab datenum, not string.
HOWEVER, this is the only code I've found that gives Azimuth round the full 360: most are 0-180 and it's up to you to find if its in the east or west... due to using code like

19 Mar 2009 Anthony Kendall

Excellent function, it's fast, compact, and easily modified for my particular needs. Thank you very much! BTW, I compared it with sun position tables, ( and it does very well.

18 Apr 2013 1.1

Vectorized routine. Added the ability to take either UTC time string, or an array of MATLAB date vectors.

Contact us