Categories &

Functions List

Class Definition: duration

Class: duration

Array representing durations of time using fixed-length time units.

duration values are stored internally as double type array representing numbers of elapsed days as a fixed-length time unit. By default, fractional seconds of duration values are not displayed, but their actual precision is closer to nanoseconds for typical time lengths.

duration arrays can be created through their constructor by combining numeric arrays representing individual fixed-length elapsed time units or through the functions years, days, hours, minutes, seconds, and calyears, which create fixed-length durations in terms of a single duration units. These functions are also available as methods of duration arrays to extract individual duration units as numeric arrays.

See also: calendarDuration, duration

Source Code: duration

Properties

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.

Methods

duration: cstr = dispstrings (D)

Get display formatted strings for each element of a duration array.

cstr = dispstrings (D) returns a cellstr array of character vectors, cstr, which has the same size as the input duration D.

duration: cstr = cellstr (D)
duration: cstr = cellstr (D, Format)

Convert duration array to a cell array of character vectors.

cstr = cellstr (D) returns a cellstr array of character vectors, cstr, which has the same size as the input duration D.

duration: cmat = char (D)

Convert duration array to a character matrix.

cmat = char (D) returns a character matrix with one row per element in D.

duration: DV = datevec (DT)
duration: [Y, MO, D, h, mi, s] = datevec (DT)

Convert duration array to date vectors.

DV = datevec (DT) returns an N×6 numeric matrix whose rows represent each element in DT and each column corresponds to years, months, days, hours, minutes, and seconds, respectively. Since months cannot be represented as a fixed length of time, the second column of DV is always zero. DV represents a length of time split accross different fixed-length elapsed time units.

[Y, MO, D, h, mi, s] = datevec (DT) returns the components of DT as individual variables, but unlike DV in the previous syntax, each variable has the same size as the duration array DT.

duration: H = hms (D)
duration: [H, M] = hms (D)
duration: [H, M, S] = hms (D)

Split duration array into separate time unit values.

[H, M, S] = hms (D) splits the duration array D into separate numeric arrays H, M, and S, which correspond to hours, minutes, and seconds, repsectively. Hours and minutes are returned as whole numbers, while seconds may also have a fractional part.

duration: X = years (D)

Duration equivalent numeric values in fixed-length years.

X = years (D) converts durations in D to the equivalent number of fixed-length years (1 year equals 365.2425 days). X is a double array of the same size as D.

duration: X = days (D)

Duration equivalent numeric values in fixed-length days.

X = days (D) converts durations in D to the equivalent number of fixed-length days (1 day equals 24 hours). X is a double array of the same size as D.

duration: X = hours (D)

Duration equivalent numeric values in hours.

X = hours (D) converts durations in D to the equivalent number of hours. X is a double array of the same size as D.

duration: X = minutes (D)

Duration equivalent numeric values in minutes.

X = minutes (D) converts durations in D to the equivalent number of minutes. X is a double array of the same size as D.

duration: X = seconds (D)

Duration equivalent numeric values in seconds.

X = seconds (D) converts durations in D to the equivalent number of seconds. X is a double array of the same size as D.

duration: X = milliseconds (D)

Duration equivalent numeric values in milliseconds.

X = milliseconds (D) converts durations in D to the equivalent number of milliseconds. X is a double array of the same size as D.

duration: sz = size (D)
duration: dim_sz = size (D, dim)
duration: dim_sz = size (D, d1, d2, …)
duration: [rows, columns, …, dim_n_sz] = size (…)

Return the size of a duration array.

sz = size (D) returns a row vector with the size (number of elements) of each dimension for the duration array D.

dim_sz = size (D, 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.

duration: out = ndims (D)

Number of dimensions in a duration array.

out = ndims (D) returns the number of dimensions of the duration array D.

duration: out = numel (D)

Total number of elements in a duration array.

For compatibility reasons with Octave’s OOP interface and subsasgn behavior, duration’s numel is defined to always return 1.

duration.isbetween is not documented.
duration.iscolumn is not documented.
duration.isempty is not documented.
duration.isequal is not documented.
duration.isequaln is not documented.
duration.isfinite is not documented.
duration.isinf is not documented.
duration.ismatrix is not documented.
duration.ismatrix is not documented.
duration.ismissing is not documented.
duration.isnan is not documented.
duration.isrow is not documented.
duration.isscalar is not documented.
duration.issorted is not documented.
duration.issortedrows is not documented.
duration.isvector is not documented.
duration.eq is not documented.
duration.ge is not documented.
duration.gt is not documented.
duration.le is not documented.
duration.lt is not documented.
duration.ne is not documented.
duration.abs is not documented.
duration.plus is not documented.
duration.uplus is not documented.
duration.minus is not documented.
duration.uminus is not documented.
duration.times is not documented.
duration.mtimes is not documented.
duration.ldivide is not documented.
duration.rdivide is not documented.
duration.colon is not documented.
duration.linspace is not documented.
duration.interp1 is not documented.
duration.sum is not documented.
duration.cumsum is not documented.
duration.diff is not documented.
duration.mean is not documented.
duration.median is not documented.
duration.mode is not documented.
duration.floor is not documented.
duration.ceil is not documented.
duration.round is not documented.
duration.sign is not documented.
duration.sort is not documented.
duration.sortrows is not documented.
duration.sortrows is not documented.
duration.intersect is not documented.
duration.setdiff is not documented.
duration.setxor is not documented.
duration.union is not documented.