フィルターのクリア

What calendar system does MATLAB use?

14 ビュー (過去 30 日間)
MathWorks Support Team
MathWorks Support Team 2009 年 6 月 27 日
編集済み: James Tursa 2023 年 11 月 27 日
What calendar system does MATLAB use?
For example, does MATLAB use the Julian calendar?

採用された回答

MathWorks Support Team
MathWorks Support Team 2009 年 6 月 27 日
MATLAB does not use any particular calendar system, such as the Julian or Gregorian calendar.
Please refer the documentation on the command DATENUM for a detailed description on how MATLAB calculates the date. You can use either 'help datenum' or 'doc datenum' in MATLAB command prompt to get detailed information on this command.
For MATLAB, the time functions begin with the CLOCK function, which returns a six-element vector:
C = [year month day hour minutes seconds]
For example, if you have the following code:
C = [2001 5 21 15 19 29];
DATESTR reformats this to:
datestr(C)
= 21-May-2001 15:19:29
DATENUM is a way of summarizing the six clock components in one double precision number (with an an accuracy of about 1.0e-5 seconds).
T = datenum(C)
which returns 730992.6385300926.
So, datenum(C) = 0 corresponds to C = [0 0 0 0 0 0], which is "day 0 of month 0 of year 0". Of course, as far as we know, no one has ever used such a calendar, but it would be the logical extrapolation of our current calendar back to times around year 0 A.D.
The Julian day number, JD, and MATLAB's datenum, T, are measuring the same thing -- number of days (and fractions of days) since some arbitrary ancient origin. One is simply an offset of the other. The Julian day number starts at noon, while the MATLAB datenum starts at midnight, so the offset involves half a day.
Here is the formula, applied to the time when you want to write this:
JD = T + 1721058.5
This returns 2452051.138530092. If you want to ignore the fraction, use the following code:
fix(JD)
which will return 2452051.

その他の回答 (1 件)

James Tursa
James Tursa 2023 年 11 月 17 日
編集済み: James Tursa 2023 年 11 月 27 日
I know this is an old post, but the accepted answer is a bit misleading. MATLAB certainly does use a specific calendar system. In particular it uses the Gregorian Calendar, and pre 15-Oct-1582 dates are assumed to be backwards extensions of this calendar rather than Julian Calendar. A comparison:
Julian Calendar with jump to Gregorian Calendar:
All years divisible by 4 are leap years (for Astronomical Convention the year 0 exists also)
The dates from Oct 5, 1582 through Oct 14, 1582 inclusive don’t exist (jump to Gregorian Calendar)
Backwards extension of Gregorian Calendar:
Years divisible by 4 except years divisible by 100 that are not divisible by 400 are leap years
The dates from Oct 5, 1582 through Oct 14, 1582 inclusive do exist
To see the difference, simply generate a datetime array near this event:
dt = datetime(1582,10,4:15)'
dt = 12×1 datetime array
04-Oct-1582 05-Oct-1582 06-Oct-1582 07-Oct-1582 08-Oct-1582 09-Oct-1582 10-Oct-1582 11-Oct-1582 12-Oct-1582 13-Oct-1582 14-Oct-1582 15-Oct-1582
format longg
jd = juliandate(dt)
jd = 12×1
1.0e+00 * 2299149.5 2299150.5 2299151.5 2299152.5 2299153.5 2299154.5 2299155.5 2299156.5 2299157.5 2299158.5
You can see that the "missing" dates for the jump from Julian Calendar to Gregorian Calendar are in fact present, and that these dates are simply backwards extensions of the Gregorian Calendar. Also, look at the dates near a Julian Leap Day:
dt = datetime(1500,2,28:30)'
dt = 3×1 datetime array
28-Feb-1500 01-Mar-1500 02-Mar-1500
jd = juliandate(dt)
jd = 3×1
1.0e+00 * 2268981.5 2268982.5 2268983.5
Although Feb 29, 1500 should exist because it is a leap year in the Julian Calendar, it does not exist in the datetime array. Again, this is because MATLAB is using a backwards extension of Gregorian Calendar leap year rules.
And Julian Date 0 is associated with this calendar date:
datetime(0,'ConvertFrom','juliandate')
ans = datetime
24-Nov--4713 12:00:00
Finally, note that the MATLAB functions will not agree with other authorities (Astronomical Algorithms by Jean Meeus and JPL/NASA website) on Julian Dates and calendar dates for these pre Gregorian epoch events. E.g., from this site:
Compare the following output with the above:
You can see that the calendar dates and Julian Dates do not match MATLAB.
Again, this isn't a MATLAB error, it is just a calendar convention difference that users should be aware of when working with pre Gregorian Calendar dates.

カテゴリ

Help Center および File ExchangeCalendar についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by