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.

equsol.m
% equsol.m             December 6, 2012     

% time of the equinoxes and soltices

% Celestial Computing with MATLAB

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

global jdatei suncoef along2 iequsol

% read leap seconds data file

readleap;

% initialize solar ephemeris

suncoef = 1;

% define root-finding tolerance

rtol = 1.0e-8;

% begin simulation

clc; home;

fprintf('\n\ntime of the equinoxes and solstices');
fprintf('\n===================================\n');

% request calendar year

fprintf('\nplease input the calendar year\n');
   
year = input('? ');

for iequsol = 1:1:4
    
    switch (iequsol)
        
    case (1)
        
       month = 3;
       
       day = 15;
       
       jdatei = julian(month, day, year);
       
    case (2)
        
       month = 6;
       
       day = 15;
       
       jdatei = julian(month, day, year);
       
       along2 = 0.5 * pi;
       
    case (3)
        
       month = 9;
       
       day = 15;
       
       jdatei = julian(month, day, year);
       
    case (4)
        
       month = 12;
       
       day = 15;
       
       jdatei = julian(month, day, year);
       
       along2 = 1.5 * pi;
       
    end
    
    % find event
    
    x1 = 0;

    x2 = 10;
    
    [xroot, froot] = brent ('esfunc', x1, x2, rtol);

    % TDB julian date
    
    jdtdb = jdatei + xroot;

    % compute UTC julian date
    
    jdutc = tdb2utc(jdtdb);
    
    [cdstr, tdtstr] = jd2str(jdutc);
    
    switch(iequsol)
        
    case (1)
        
       fprintf('\nspring equinox');
       fprintf('\n--------------\n');
       
    case (2)
        
       fprintf('\nsummer solstice');
       fprintf('\n---------------\n');
       
    case (3)
        
       fprintf('\nfall equinox');
       fprintf('\n------------\n');
       
    case (4)
        
       fprintf('\nwinter solstice');
       fprintf('\n---------------\n');
       
    end
    
    fprintf('\ncalendar date         ');

    disp(cdstr);

    fprintf('UTC time              ');

    disp(tdtstr);
    
end

fprintf('\n\n');

Contact us