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.

tranprt(iflag, jdutc)
function tranprt(iflag, jdutc)

% print transit conditions 

% required by transit.m

% Celestial Computing with MATLAB

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

global azimuth elevation jdsaved itarget

% convert julian day to calendar date
% and universal time strings

[cdstr, utstr] = jd2str(jdutc);

if (iflag == 1)
    
   if (itarget == 1)
       
      fprintf('\n\ningress - exterior contact - Mercury');
      fprintf('\n------------------------------------\n\n');
      
   else
       
      fprintf('\n\ningress - exterior contact - Venus');
      fprintf('\n----------------------------------\n\n');
      
   end 
   
   jdsaved = jdutc;
   
end

if (iflag == 2)
    
   if (itarget == 1)
       
      fprintf('\n\nleast distance of the Sun and Mercury');
      fprintf('\n-------------------------------------\n\n');
      
   else
       
      fprintf('\n\nleast distance of the Sun and Venus');
      fprintf('\n-----------------------------------\n\n');
      
   end  
   
end

if (iflag == 3)
    
   if (itarget == 1)
       
      fprintf('\n\negress - exterior contact - Mercury');
      fprintf('\n-----------------------------------\n\n');
      
   else
       
      fprintf('\n\negress - exterior contact - Venus'); 
      fprintf('\n---------------------------------\n\n');
      
   end 
   
end

fprintf('calendar date             ');

disp(cdstr);

fprintf('\nuniversal time            ');

disp(utstr);

fprintf('\n');

fprintf('UTC Julian date           %10.4f \n', jdutc);

% display topocentric angles and slant range

[d, m, s, azimstr] = deg2dms (azimuth);

[d, m, s, elevstr] = deg2dms (elevation);

fprintf('\nazimuth angle of the sun        ');

disp(azimstr);

fprintf('\nelevation angle of the sun      ');

disp(elevstr);

% determine event duration

if (iflag == 3)
    
   deltat = 24 * (jdutc - jdsaved);
   
   [h, m, s, hmsstr] = hrs2hms (deltat);
   
   fprintf('\n\nevent duration                  ');
   
   disp(hmsstr);
   
end


Contact us