Code covered by the BSD License  

Highlights from
Rise and Set of the Sun, Moon and Planets

Rise and Set of the Sun, Moon and Planets

by

 

05 Dec 2012 (Updated )

Topocentric rise and set of the Sun, Moon and planets. Source ephemeris is DE421 with NOVAS routines

hrs2hms (hrs)
function [h, m, s, hmsstr] = hrs2hms (hrs)

% convert decimal hours to hours,
% minutes, seconds and equivalent string

% Celestial Computing with MATLAB

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if (hrs < 0)
   hrs = hrs + 24;
end

h = abs(hrs);
   
d = fix(h);
   
d1 = (h - d) * 60;
   
m = fix(d1);
   
s = (d1 - m) * 60;
    
hmsstr = sprintf('%+03d%s%02d%s%06.4f%s', d,...
            'h ', m, 'm ', s,'s');

 


Contact us