duration

Methods

Method Reference: duration.issorted

duration: TF = issorted (D)
duration: TF = issorted (D, dim)
duration: TF = issorted (D, direction)
duration: TF = issorted (D, dim, direction)
duration: TF = issorted (…, 'MissingPlacement', MP)
duration: TF = issorted (…, 'ComparisonMethod', CM)

Return true if duration array is sorted.

TF = issorted (D) returns a logical scalar TF, which is true, if the duration array D is sorted in ascending order, and false otherwise.

TF = issorted (D, dim) returns a logical scalar TF, which is true, if the duration array D is sorted in ascending order along the dimension dim, and false otherwise.

TF = issorted (D, direction) returns a logical scalar TF, which is true, if the duration array D is sorted in the direction specified by direction, and false otherwise. direction can be any of the following options:

  • 'ascend', which is the default, checks is elements are in ascending order.
  • 'descend' checks if elements are in descending order.
  • 'monotonic' checks if elements are either in ascending or descending order.
  • 'strictascend' checks if elements are in ascending order and there are no duplicate or undefined elements.
  • 'strictdescend' checks if elements are in descending order and there are no duplicate or undefined elements.
  • 'strictmonotonic' checks if elements are either in ascending or descending order and there are no duplicate or undefined elements.

TF = issorted (…, 'MissingPlacement', MP) specifies where missing elements (NaN) are placed with one of the following options specified in MP:

  • 'auto', which is the default, places missing elements last for ascending sort and first for descending sort.
  • 'first' places missing elements first.
  • 'last' places missing elements last.

TF = issorted (…, 'ComparisonMethod', CM) specifies the comparison method for determining the order of elements with one of following options specified in CM:

  • 'auto', which is the default, sorts by real (A).
  • 'real' sorts by real (A).
  • 'abs' sorts by abs (A).

Source Code: duration

Example: 1

issorted checks whether the durations are already in non-decreasing order.

 issorted (hours ([1, 2, 3]))
ans = 1
 issorted (hours ([2, 1, 3]))
ans = 0