calendarDuration
Array representing durations of time using flexible-length calendar date/time units.
Each calendarDuration
element stores internally the number of whole
months, the number of whole days, and a duration
object representing
hours, minutes, and seconds. It can be used to simplify calculations on
datetime
arrays involving calendar units.
calendarDuration
arrays can be created through their constructor by
combining numeric arrays representing individual calendar duration units or
through the functions caldays
, calweeks
, calmonths
,
calquarters
, and calyears
, which create calendar durations in
terms of a single calendar duration unit. These functions are also
available as methods of calendarDuration
arrays to extract
individual calendar duration units as numeric arrays.
Source Code: calendarDuration
Display format, specified as a character vector or string scalar. If specified as a string scalar, it is converted and stored internally as a character vector.
'Format'
, FMT)Create a new array of calendar durations.
calD = calendarDuration (X)
returns an array of
calendar durations from numeric matrix X, which must have either
three or six columns, representing years, months, days, hours, minutes,
and seconds, accordingly. All but seconds must be represented as whole
duration units by integer values.
calD = calendarDuration (Y, MO, D)
returns
an array of calendar durations from numeric arrays Y, MO, and
D, which correspond to years, months, and days, respectively. The
size of calD is the common size of the numeric input arguments,
which must be of the same size or scalars. A scalar input functions as a
constant array of the same size as the other inputs.
calD = calendarDuration (Y, MO, D, H,
MI, S)
returns an array of calendar durations from numeric
arrays Y, MO, D, H, MI, and S, which
correspond to years, months, days, hours, minutes, and seconds,
respectively. The size of calD is the common size of the numeric
input arguments, which must be of the same size or scalars. A scalar
input functions as a constant array of the same size as the other inputs.
calD = calendarDuration (Y, MO, D,
T)
returns an array of calendar durations from numeric arrays
Y, MO, and D, which correspond to years, months, and
days, as well as a time duration array T. The size of calD
is the common size of the data input arguments, which must be of the same
size or scalars. A scalar input functions as a constant array of the
same size as the other inputs.
Numeric input arrays Y, MO, D, H, and MI must contain integer values corresponding to whole calendar units. S can also be contain fractions of seconds.
calD = calendarDuration (…,
specifies the format in which calD is displayed.
FMT must be a character vector containing the following letters.
'Format'
,
FMT)
'y'
years
'q'
quarters of a year
'm'
months
'w'
weeks
'd'
days
't'
time duration
calD = calendarDuration ()
returns a scalar array of
calendar durations with a value of zero days. To create an empty
calendarDuration array, use calendarDuration ([], [], [])
.
See also: calyears, calquarters, calmonths, calweeks, caldays, calendarDuration, iscalendarduration, datetime, duration
Get display formatted strings for each element of a calendarDuration array.
cstr = dispstrings (calD)
returns a cellstr array of
character vectors, cstr, which has the same size as the input
calendarDuration array, calD.
Convert calendarDuration array to a cell array of character vectors.
cstr = cellstr (calD)
returns a cellstr array of
character vectors, cstr, which has the same size as the input
calendarDuration calD.
Convert calendarDuration array to a character matrix.
cmat = char (calD)
returns a character matrix with
one row per element in calD.
Convert calendarDuration array to date vectors.
DV = datevec (calD)
returns a numeric matrix with
one row per element in calD.
Return time portion of calendarDuration array.
T = time (calD)
returns a duration array T with
the time portions of the calendarDuration array calD.
Split calendarDuration array into numeric time units.
[…] = split (calD, units)
splits the calendar
duration units in calD into separate numeric arrays according to
date/time units specified in units, which must be either a cell
array of character vectors or a string array containing any of the
following date/time units in descending order.
'years'
'quarters'
'months'
'weeks'
'days'
'time'
When a single date/time unit is specified, units may also be a
character vector. When 'time'
is specified in units, the
corresponding returning argument is a duration
array. The values
of years, quarters, and months are computed independently from the values
of weeks and days in calD, with larger units taking precedence when
specified The same applies for duration arrays, when requested.
Calendar duration in days.
X = caldays (calD)
returns a numeric array with the
number of days as represented in calD.
caldays
is also available as a function, in which case it performs
the opposite conversion.
See also: calendarDuration.calyears, calendarDuration.calquarters, calendarDuration.calmonths, calendarDuration.calweeks, caldays
Calendar duration in weeks.
X = calweeks (calD)
returns a numeric array with the
number of weeks as represented in calD.
calweeks
is also available as a function, in which case it
performs the opposite conversion.
See also: calendarDuration.calyears, calendarDuration.calquarters, calendarDuration.calmonths, calendarDuration.caldays, calweeks
Calendar duration in months.
X = calmonths (calD)
returns a numeric array with the
number of months as represented in calD.
calmonths
is also available as a function, in which case it
performs the opposite conversion.
See also: calendarDuration.calyears, calendarDuration.calquarters, calendarDuration.calweeks, calendarDuration.caldays, calmonths
Calendar duration in quarters.
X = calmonths (calD)
returns a numeric array with the
number of quarters as represented in calD.
calmonths
is also available as a function, in which case it
performs the opposite conversion.
See also: calendarDuration.calyears, calendarDuration.calmonths, calendarDuration.calweeks, calendarDuration.caldays, calquarters
Calendar duration in years.
X = calmonths (calD)
returns a numeric array with the
number of years as represented in calD.
calmonths
is also available as a function, in which case it
performs the opposite conversion.
See also: calendarDuration.calquarters, calendarDuration.calmonths, calendarDuration.calweeks, calendarDuration.caldays, calyears
Size of a calendarDuration array.
sz = size (calD)
returns a row vector with the size
(number of elements) of each dimension for the calendar duration array
calD.
dim_sz = size (calD, dim)
returns the size of
the corresponding dimension specified in dim. If dim is a
vector, then dim_sz is a vector of the same length and with each
element corresponding to a specified dimension. Multiple dimensions may
also be specified as separate arguments.
With a single output argument, size
returns a row vector. When
called with multiple output arguments, size
returns the size of
dimension N in the Nth argument.
Number of dimensions in a calendarDuration array.
out = ndims (calD)
returns the number of dimensions
of the calendar duration array calD.
Total number of elements in a calendarDuration array.
For compatibility reasons with Octave’s OOP interface and subsasgn
behavior, calendarDuration’s numel
is defined to always return 1.
Number of nonzero elements in calendarDuration array.
out = nns (calD)
returns the number of nonzero
elements in the calendar duration array calD.
Return true if calendarDuration array is a column vector.
Return true if calendarDuration array is empty.
Return true if all calendarDuration arrays are equal.
Return true if all calendarDuration arrays are equal under the additional
assumption that NaN == NaN
.
Return a logical array which is true where the elements of calendarDuration array calD are finite and false where they are not. TF and calD are of the same size.
Return a logical array which is true where the elements of calendarDuration array calD are infinite and false where they are not. TF and calD are of the same size.
Return true if calendarDuration array is a 2-D array.
Find missing data in a calendar duration array.
Missing values in calendarDuration arrays are represented by NaN
,
thus TF = ismissing (calD)
is equivalent to
TF = isnan (calD)
.
Note: ismissing
for calendarDuration arrays does not support a
second Indicator arguments.
Return a logical array which is true where the elements of calD are
NaN
values and false where they are not. TF and calD
are of the same size.
Return true if calendarDuration array is a row vector.
Return true if calendarDuration array is a scalar.
Return true if calendarDuration array is a vector.
calendarDuration.minus
is not documented.
calendarDuration.uminus
is not documented.
calendarDuration.plus
is not documented.
calendarDuration.uplus
is not documented.
calendarDuration.sort
is not documented.
calendarDuration.sortrows
is not documented.
calendarDuration.unique
is not documented.
calendarDuration.interp1
is not documented.
calendarDuration.intersect
is not documented.
calendarDuration.setdiff
is not documented.
calendarDuration.setxor
is not documented.
calendarDuration.union
is not documented.