convert Modified Julian Date

10 Ansichten (letzte 30 Tage)
Kate L.
Kate L. am 14 Nov. 2011
I am importing a .dat file that has MJD in the form of "55743.21235" and if converted in Excel (by taking the cell-50813) is 06/30/11 05:05:47. This is cummlative file with years worth of data but each quarter, I am only interested in the current quarter(i.e. Oct 01, 2011-Dec 31, 2011).
How can I convert/change each of the MJDs (in a single column of over +1000 MJDs) that I import into the more meaningful form of 'dd:mmm:yyyy' or 'mmm:dd:yyyy'? Once the conversion is complete, the user will be queried to select a time frame, or quarter, of interest. The HH:MM:SS aren't required. Thanks, Kate

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 15 Nov. 2011
The difference between datenum('06/30/11 05:05:47') (your proposed translation) and 55743.21235, is 678941
However, datenum('Nov 17, 1858,00:00') is 678942, which is a one day difference compared to your proposal.
The Nov 17, 1858 00:00 date is listed in Wikipedia, and the 678942 offset is exactly that needed to properly convert the example MJD 49987 to September 27, 1995, as documented in the US Naval Observatory web site
The evidence would seem to suggest that your calculations are off by exactly one day, and that Fangjun's calculations are correct.
  1 Kommentar
Kate L.
Kate L. am 16 Nov. 2011
works perfectly...thank you!
mjd = data(1:end,1) %mjd in the form 55743.21235
mjdconv = mjd+678942
datestr(mjdconv)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Fangjun Jiang
Fangjun Jiang am 14 Nov. 2011
You can use datestr(),datenum() and datevec() function. Try this:
a=now;
b=datestr(a)
c=datevec(a)
According to Wikipedia, http://en.wikipedia.org/wiki/Julian_day, the epoch (commencing time) of MJD is 00:00 November 17, 1858, Wednesday. So,
d = 55743.21235;
MJD_epoch='Nov 17, 1858,00:00';
datestr(d+datenum(MJD_epoch))
ans =
01-Jul-2011 05:05:47
I am not sure why it's still off one day (according to you). Are you sure you got the correct day?
  3 Kommentare
Fangjun Jiang
Fangjun Jiang am 14 Nov. 2011
You mentioned an offset of 50813?
a=55743.21235;
b=a-50813;
datestr(a)
datestr(b)
Fangjun Jiang
Fangjun Jiang am 14 Nov. 2011
datestr() and datenum() can specify pivot year too. See the document.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Dates and Time finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by