datetime

Methods

Method Reference: datetime.mean

datetime: M = mean (A)
datetime: M = mean (A, dim)
datetime: M = mean (A, 'all')
datetime: M = mean (…, nanflag)

Mean of a datetime array.

M = mean (A) returns the mean of the datetime array A as a scalar datetime, computed as the average of the absolute instants along the first non-singleton dimension. A dim or 'all' argument selects the dimension(s) to operate on. The result carries the Format and TimeZone of A.

By default a Not-A-Time element makes the corresponding result NaT; pass 'omitnat' (equivalently 'omitmissing') to ignore missing values, or 'includenat' to keep the default.

Source Code: datetime

mean returns the midpoint instant of the datetimes.

 t = datetime (2024, 3, [1, 9, 20])
t =
  1x3 datetime array

    01-Mar-2024    09-Mar-2024    20-Mar-2024
 mean (t)
ans =
  datetime

   10-Mar-2024