Method Reference: calendarDuration.plus

calendarDuration: C = plus (A, B)

Addition for calendarDuration arrays.

C = plus (A, B) is the equivalent of the syntax C = A + B and returns the result of adding the corresponding elements of A and B. C is a calendarDuration array of the same size as the input arguments after the necessary (if required) expansion. 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.

Either A or B may also be a duration or a numeric array with the latter representing duration days and being internally converted to a duration array with the days () function.

Source Code: calendarDuration

Example: 1

plus (+) adds calendar durations. Because the units are calendar units, the sum normalises on display (here 6 + 9 months rolls into a year).

 a = calyears (1) + calmonths (6)
a =
  calendarDuration

   1y 6mo
 a + calmonths (9)
ans =
  calendarDuration

   2y 3mo