function [year, month, day] = mjd2ymd(mjd)

% function [year, month, day] = mjd2ymd(mjd)
% From Meeus (p. 63)
% by kaj.wiik@hut.fi (25 Jan 1996)
% 

jd = mjd + 2400000.5;
jd = jd + .5;
z = fix(jd);
f = jd - z;

alpha = fix((z - 1867216.25)/36524.25);
a = z + 1 + alpha - fix(alpha/4);

b = a + 1524;
c = fix((b - 122.1)/365.25);
d = fix(365.25*c);
e = fix((b - d)/30.6001);

day = b - d - fix(30.6001*e) + f;

if e < 14
  month = e - 1;
else
  month = e - 13;
end

if month > 2
  year = c - 4716;
else
  year = c - 4715;
end

