corresponds to the start of the current month, and 4 corresponds to the start of the fourth
month from t1.
t1 = datetime(2014,04,01);
t = dateshift(t1,'start','month',0:4)
t = 1x5 datetime array
01-Apr-2014 01-May-2014 01-Jun-2014 01-Jul-2014 01-Aug-2014
Dates at End of Month
Generate a sequence of end-of-month dates beginning with April 1, 2014.
t1 = datetime(2014,04,01);
t = dateshift(t1,'end','month',0:2)
t = 1x3 datetime array
30-Apr-2014 31-May-2014 30-Jun-2014
Determine the number of days between each date.
dt = caldiff(t,'days')
dt = 1x2 calendarDuration array
31d 30d
The dates are not equally spaced.
Other Units of Dates and Time
You can specify other units of time such as week, day, and hour.
t1 = datetime('now')
t1 = datetime
13-Apr-2019 03:03:11
t = dateshift(t1,'start','hour',0:4)
t = 1x5 datetime array
Columns 1 through 3
Generate Sequence of Dates and Time