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.

getdate
function [m, d, y] = getdate

% interactive request and input of calendar date

% output

%  m = calendar month
%  d = calendar day
%  y = calendar year

% Celestial Computing with MATLAB

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

while (1)
  fprintf('\nplease input the calendar date');

  fprintf('\n(1 <= month <= 12, 1 <= day <= 31, year = all digits!)\n');

  cdstr = input('? ', 's');
  
  tl = size(cdstr);
  
  ci = findstr(cdstr, ',');
  
  % extract month, day and year
  
  m = str2num(cdstr(1:ci(1)-1));

  d = str2num(cdstr(ci(1)+1:ci(2)-1));

  y = str2num(cdstr(ci(2)+1:tl(2)));
  
  % check for valid inputs
  
  if (m >= 1 & m <= 12 & d >= 1 & d <= 31)
     break;
  end
end

Contact us