Method Reference: calendarDuration.eq

calendarDuration: TF = eq (A, B)

Test for equality between calendarDuration arrays.

TF = eq (A, B) is the equivalent of the syntax TF = A == B and returns a logical array with elements set to true where calendarDuration arrays A and B are equal, otherwise set to false. Missing values are not equal to each other. Hence, any NaN values in A or B result to false elements in TF.

A and B must be size compatible, which translates to they can be the same size, one can be scalar, or for every dimension, their dimension sizes must be equal or one of them must be 1. The size of the output TF is the same as the size of input arrays after their expansion according to the broadcasting rules.

MATLAB defines no equality for calendarDuration arrays, so this is an Octave extension. Two spans are compared component by component, which is what MATLAB’s own isequal does, so the two agree element for element: calweeks (1) == caldays (7) is true, both being seven days, while caldays (1) == calendarDuration (0, 0, 0, 24, 0, 0) is false, a day and twenty-four hours sitting in different components.

Source Code: calendarDuration

eq (==) tests calendar durations for equality. Equivalent spans compare equal even when written with different builders.

 calmonths (12) == calyears (1)
ans = 1
 calweeks (2) == caldays (14)
ans = 1