datetime.unique
datetime: B = unique (A)
datetime: B = unique (A, setOrder)
datetime: B = unique (A, occurrence)
datetime: B = unique (A, setOrder, occurrence)
datetime: B = unique (A, occurrence, setOrder)
datetime: B = unique (A, …, 'rows')
datetime: [B, ixA, ixB] = unique (…)
Unique values in a datetime array.
B = unique (A) returns the unique values of the
datetime array A in sorted order.
B = unique (A, setOrder) returns the unique
values of the datetime array A in an order as specified by
setOrder, which can be either of the following values:
'sorted' (default) returns the unique values sorted in
ascending order.
'stable' returns the unique values according to their order
of occurrence.
B = unique (A, occurrence) returns the unique
values of the datetime array tblA according to their order of
occurrence. occurrence can be either of the following values:
'first' (default) returns the first occurrence of each
unique value, i.e. the lowest possible indices are returned.
'last' returns the last occurrence of each unique value,
i.e. the highest possible indices are returned.
You can specify setOrder and occurrence arguments together.
B = unique (A, …, returns the
unique rows of A by treating each row as a single entity. The
'rows')'rows' option can be used alone or in any combination with the
setOrder and occurrence arguments. 'rows' can be
placed at any position in the function’s argument list after the input
array A. However, this syntax is only valid for 2-dimensional
datetime arrays.
[tblB, ixA, ixB] = unique (…) also returns
index vectors ixA and ixB using any of the previous syntaxes.
ixA and ixB map the arrays A and B to one another
such that B = A(ixA) and
A = B(ixB). When the 'rows' optional
argument is specified, then B = A(ixA,:) and
tblA = tblB(ixB,:).
Source Code: datetime
unique returns the distinct datetimes in sorted order.
t = datetime (2024, 1, [3, 1, 3, 2, 1])
t =
1x5 datetime array
03-Jan-2024 01-Jan-2024 03-Jan-2024 02-Jan-2024 01-Jan-2024
unique (t)
ans =
1x3 datetime array
01-Jan-2024 02-Jan-2024 03-Jan-2024