convert Modified Julian Date
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (1)
Fangjun Jiang
el 14 de Nov. de 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 comentarios
Kate L.
el 14 de Nov. de 2011
Fangjun Jiang
el 14 de Nov. de 2011
You mentioned an offset of 50813?
a=55743.21235;
b=a-50813;
datestr(a)
datestr(b)
Fangjun Jiang
el 14 de Nov. de 2011
datestr() and datenum() can specify pivot year too. See the document.
Categorías
Más información sobre Dates and Time en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!