Sandia National Laboratories has developed a function that approximates the position of the sun quite accurately. This function, along with Matlab source code, is available as part of the PV_LIB Toolbox. The function is pvl_ephemeris. The calculation is based on an internal course, Engineering Astronomy, developed by Grover Hughes, and documents in these class notes Engineering-Astronomy.pdf (8077 downloads) .