Categories &

Functions List

Class Definition: duration

datatypes: 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, datetime

Source Code: duration

The duration class contains the following 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.

The duration class offers the following public methods:

duration Create a new array of fixed-length time durations.
dispstrings Get display formatted strings for each element of a duration array.
cellstr Convert duration array to a cell array of character vectors.
char Convert duration array to a character matrix.
datevec Convert duration array to date vectors.
hms Split duration array into separate time unit values.
years Duration equivalent numeric values in fixed-length years.
days Duration equivalent numeric values in fixed-length days.
hours Duration equivalent numeric values in hours.
minutes Duration equivalent numeric values in minutes.
seconds Duration equivalent numeric values in seconds.
milliseconds Duration equivalent numeric values in milliseconds.
size Return the size of a duration array.
ndims Number of dimensions in a duration array.
numel Total number of elements in a duration array.
nnz Number of nonzero elements in duration array.
length Length of a duration vector.
keyHash Generate a hash code for duration array.
isbetween Find duration elements within specified range.
iscolumn Return true if duration array is a column vector.
isempty Return true if duration array is empty.
isequal Return true if duration arrays are equal.
isequaln Return true if duration arrays are equal under the assumption that missing elements are equal.
isfinite Return true for duration elements that are finite.
isinf Return true for duration elements that are infinite.
ismatrix Return true if duration array is a 2-D array.
ismember Find duration elements in a set.
ismissing Find missing elements in duration array.
isnan Return true for duration elements that are Not-A-Number.
isrow Return true if duration array is a row vector.
isscalar Return true if duration array is a scalar.
issorted Return true if duration array is sorted.
issortedrows Return true if duration matrix rows are sorted.
isvector Return true if duration array is a vector.
eq Equality for duration arrays.
ge Equality for duration arrays.
gt Equality for duration arrays.
le Equality for duration arrays.
lt Equality for duration arrays.
ne Equality for duration arrays.
abs Absolute value of the elements of a duration array.
plus Addition for duration arrays.
uplus Unary plus for duration arrays.
minus Subtraction for duration arrays.
uminus Unary minus for duration arrays.
times Element-wise multiplication for duration arrays.
mtimes Matrix multiplication for duration arrays.
ldivide Element-wise left division for duration arrays.
rdivide Element-wise right division for duration arrays.
colon Create a range of durations in a vector.
linspace Create linearly spaced duration elements.
diff Compute differences between adjacent elements in a duration array.
sum Compute the sum of the elements of a duration array.
cumsum Compute the cumulative sum of the elements of a duration array.
min Find minimum values in duration arrays.
cummin Return the cumulative minimum values in duration arrays.
max Find maximum values in duration arrays.
cummax Return the cumulative maximum values in duration arrays.
floor Round toward negative infinity for duration arrays.
ceil Round toward negative infinity for duration arrays.
round Round to the nearest integer time unit for duration arrays.
sign Compute the signum function for duration arrays.
bounds Return the smallest and largest values of a duration array.
center Center values in a duration array.
histc Compute histogram counts in a duration array.
iqr Compute the interquartile range of a duration array.
kurtosis Compute the sample kurtosis of a duration array.
mad Compute the mean or median absolute deviation of a duration array.
mape Compute the mean absolute percentage error between duration arrays.
mean Compute the mean of the elements of a duration array.
median Compute the median value of the elements of a duration array.
mode Compute the most frequently occurring value in a duration array.
prctile Compute the percentiles of a duration array.
quantile Compute the quantiles of a duration array.
range Compute the range of a duration array.
rmse Compute the root mean squared error between duration arrays.
skewness Compute the sample skewness of a duration array.
std Compute the standard deviation of a duration array.
sort Sort elements in a duration array.
sortrows Sort rows in a duration array.
unique Unique values in a duration array.
interp1 One-dimensional interpolation for duration arrays.
intersect Set intersection of two duration arrays.
setdiff Set difference of two duration arrays.
setxor Set exclusive-or of two duration arrays.
union Set union of two duration arrays.
cat Concatenate duration arrays.
horzcat Horizontal concatenation of duration arrays.
vertcat Vertical concatenation of duration arrays.
repmat Repeat copies of a duration array.
repelem Repeat copies of duration array elements.
repelems Construct a vector of repeated duration array.
reshape Reshape duration array.
circshift Circularly shift the elements in a duration array.
permute Generalized transpose for a duration N-D array.
ipermute Inverse of the generalized transpose for a duration N-D array.
transpose Transpose a duration matrix.
ctranspose Transpose a duration matrix.