convert Modified Julian Date
显示 更早的评论
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
采纳的回答
更多回答(1 个)
Fangjun Jiang
2011-11-14
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 个评论
Kate L.
2011-11-14
Fangjun Jiang
2011-11-14
You mentioned an offset of 50813?
a=55743.21235;
b=a-50813;
datestr(a)
datestr(b)
Fangjun Jiang
2011-11-14
datestr() and datenum() can specify pivot year too. See the document.
类别
在 帮助中心 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!