mustBeSorted
Description
mustBeSorted( throws an error if the
elements of A)A are not in sorted order. This function does not return a
value. mustBeSorted calls the issorted function to determine if the elements in A are sorted.
If
Ais a vector, the elements ofAare considered sorted if they are in ascending order.If
Ais a matrix, the elements ofAare considered sorted if each column is in ascending order.If
Ais a multidimensional array, the elements ofAare considered sorted if they are in ascending order along the first dimension whose size does not equal 1.If
Ais a timetable,Ais considered sorted if its row time vector is in ascending order.
Class support: All numeric classes, logical,
char, string, cell,
categorical, datetime, duration,
timetable, and MATLAB® classes that implement issorted.
mustBeSorted(___,
specifies the sorting direction in addition to any of the input argument combinations in any
of the previous syntaxes. For example, direction)mustBeSorted(A,"monotonic") throws
an error if the elements of A are not in ascending or descending
order.
mustBeSorted(___,
specifies additional options for checking sort order using one or more name-value arguments.
For example, for an input array Name=Value)A that contains complex values,
mustBeSorted(A,ComparisonMethod="abs") throws an error if the elements
of A are not sorted by their complex magnitude.
Examples
Input Arguments
Name-Value Arguments
Tips
mustBeSortedis designed to be used for property and function argument validation.