duration

Methods

Method Reference: duration.setdiff

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

Set difference of two duration arrays.

C = setdiff (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 = setdiff (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.

… = setdiff (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] = setdiff (…) also returns the index vector ixA such that C = A(ixA), unless the 'rows' optional argument is given, in which case C = A(ixA,:).

Source Code: duration

Example: 1

setdiff returns the durations in the first array but not the second.

 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
 setdiff (A, B)
ans =
  duration

   1 hr