Code covered by the BSD License  

Highlights from
A MATLAB Script for Predicting Transits of Mercury and Venus

A MATLAB Script for Predicting Transits of Mercury and Venus

by

 

07 Dec 2012 (Updated )

Local circumstances of solar transits of the planets Mercury and Venus.

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