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

deg2dms (dd)
function [d, m, s, dmsstr] = deg2dms (dd)

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

% Celestial Computing with MATLAB

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

d1 = abs(dd);
   
d = fix(d1);
   
d1 = (d1 - d) * 60;
   
m = fix(d1);
   
s = (d1 - m) * 60;
    
if (dd < 0)
   if (d ~= 0)
      d = -d;
   elseif (m ~= 0)
      m = -m;
   else
      s = -s;
   end
end

dmsstr = sprintf('%+03d%s%02d%s%05.2f%s', d,...
            'd ', m, 'm ', s,'s');

 


Contact us