duration

Methods

Method Reference: duration.colon

duration: R = colon (Base, Limit)
duration: R = colon (Base, Increment, Limit)

Create a range of durations in a vector.

R = colon (Base, Limit) is the equivalent of the syntax C = Base:Limit and returns a duration vector in the range from Base to Limit incremented by 24-hour days.

R = colon (Base, Increment, Limit) is equivalent to C = Base:Increment:Limit. dimension sizes must be equal or one of them must be 1. The size of C is determined by the size compatibility of A and B.

As long as one of the inputs is a duration scalar, the following types are additionally supported for the remaining input arguments:

  • numeric scalar (24-hour day)
  • character vector (duration string)
  • cellstr scalar (duration string)
  • string scalar (duration string)

Source Code: duration

Example: 1

The colon operator builds an evenly-spaced range of durations, using a duration step — here every half hour from 0 to 2 hours.

 hours (0):minutes (30):hours (2)
ans =
  1x5 duration array

    0 hr    0.5 hr    1 hr    1.5 hr    2 hr