calendarDuration.datevec
calendarDuration: DV = datevec (calD)
calendarDuration: [Y, MO] = datevec (calD)
calendarDuration: [Y, MO, D] = datevec (calD)
calendarDuration: [Y, MO, D, H] = datevec (calD)
calendarDuration: [Y, MO, D, H, MI] = datevec (calD)
calendarDuration: [Y, MO, D, H, MI, S] = datevec (calD)
Convert calendarDuration array to date vectors.
DV = datevec (calD) returns an numeric
matrix, where is the number of elements in calD and the
columns corresponds to years, months, days, hours, minutes, and seconds,
respectively.
When datevec is called with more than one output arguments, then
it returns the components of the date vectors as individual variables
Y, MO, D, H, MI,and S corresponding
to years, months, days, hours, minutes, and seconds, respectively. In
this case, the individual variables have the same size as the input array
calD.
Every component carries the sign of the span as a whole, so a negative
calendar duration returns negative components throughout. An element
that is not finite has no components to divide between: all six take that
same infinity, or NaN, which is what split returns for it
as well.
Source Code: calendarDuration
datevec returns the span as a numeric row [Y MO D H MI S] per element, handy for feeding the raw components into other calculations.
d = calendarDuration (1, 2, 3, 4, 5, 6)
d = calendarDuration 1y 2mo 3d 4h 5m 6s
datevec (d)
ans = 1 2 3 4 5 6
An element that is not finite has no components to divide between, so all six take that same infinity — the same answer split gives for it.
d = calendarDuration ([1, Inf, NaN], 2, 3)
d =
1x3 calendarDuration array
1y 2mo 3d Inf NaN
datevec (d)
ans =
1.0000 2.0000 3.0000 0 0 0
Inf Inf Inf Inf Inf Inf
NaN NaN NaN NaN NaN NaN