Note: This page has been translated by MathWorks. Please click here

To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

Calendar math successive differences

`dt = caldiff(t)`

`dt = caldiff(t,components)`

`dt = caldiff(t,components,dim)`

calculates
time differences between adjacent datetime values in `dt`

= caldiff(`t`

)`t`

in
terms of the calendar components years, months, days, and time. `caldiff`

calculates
differences along the first array dimension whose size does not equal
1.

If

`t`

is a vector of length`m`

, then`dt = caldiff(t)`

returns a vector of length`m-1`

. The elements of`dt`

are the differences between adjacent elements of`t`

.dt = [between(t(1),t(2)), between(t(2),t(3)),..., between(t(m-1),t(m))]

If

`t`

is a nonvector`p`

-by-`m`

matrix, then`dt = caldiff(t)`

returns a matrix of size`(p-1)`

-by-`m`

, whose elements are the differences between the rows of`t`

.dt(:,I) = [between(t(1,I),t(2,I), between(t(2,I),t(3,I)), ...,

between(t(p-1,I),t(p,I))]

finds
the differences between successive datetimes in `dt`

= caldiff(`t`

,`components`

)`t`

in
terms of the specified calendar or time components.

finds
the differences between successive datetimes along the dimension specified
by `dt`

= caldiff(`t`

,`components`

,`dim`

)`dim`

.

To compute successive differences between datetimes in

`t1`

and`t2`

as exact, fixed-length units of hours, minutes, and seconds, use`diff(t)`

.

`between`

| `calendarDuration`

| `diff`

| `minus`

Was this topic helpful?