duration.union
duration: C = union (A, B)
duration: C = union (A, B, 'rows')
duration: C = union (A, B, …, order)
duration: [C, ixA, ixB] = union (…)
Set union of two duration arrays.
C = union (A, B) returns the unique common
values of the duration arrays A and B. Either A or
B input arguments can also be a duration string specified as a
character vector, a string array, or a cell array of character vectors,
or a numeric array representing 24-hour days. In such case, the input is
promoted to a duration array prior to calculating the intersection. If
both A and B are row vectors, then C is also a row
vector, otherwise intersect returns a column vector.
C = union (A, B, returns the
unique common rows of the duration matrices A and B, which
must have the same number of columns. By default, the rows in
duration matrix C are in sorted order.
'rows'
… = union (A, B, …, order) also
specifies the order of the returned unique values. order can be
'sorted', which is the default behavior, or 'stable', in
which case the unique values are returned in order of appearance.
[C, ixA, ixB] = union (…) also returns
index vectors ixA and ixB such that
C = A(ixA) and
C = B(ixB), unless the 'rows' optional
argument is given, in which case C = A(ixA,:)
and C = B(ixB,:).
Source Code: duration
union returns the distinct durations present in either array.
A = hours ([1, 2, 3])
A =
1x3 duration array
1 hr 2 hr 3 hr
B = hours ([2, 3, 4])
B =
1x3 duration array
2 hr 3 hr 4 hr
union (A, B)
ans =
1x4 duration array
1 hr 2 hr 3 hr 4 hr