duration

Methods

Method Reference: duration.setxor

duration: C = setxor (A, B)
duration: C = setxor (A, B, 'rows')
duration: C = setxor (A, B, …, order)
duration: [C, ixA, ixB] = setxor (…)

Set exclusive-or of two duration arrays.

C = setxor (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 = setxor (A, B, 'rows' 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.

… = setxor (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] = setxor (…) 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

Example: 1

setxor returns the symmetric difference — durations in exactly one 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
 setxor (A, B)
ans =
  1x2 duration array

    1 hr    4 hr