duration.intersect
duration: C = intersect (A, B)
duration: C = intersect (A, B, 'rows')
duration: C = intersect (A, B, …, order)
duration: [C, ixA, ixB] = intersect (…)
Set intersection of two duration arrays.
C = intersect (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 = intersect (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'
… = intersect (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] = intersect (…) 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
intersect returns the durations common to two arrays.
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
intersect (A, B)
ans =
1x2 duration array
2 hr 3 hr