MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

Create a sequence of datetime values spaced one fixed-length day apart,


t = t1:days(1):t2


t = 1x5 datetime array
Columns 1 through 3


01-Nov-2013 08:00:00 02-Nov-2013 08:00:00 03-Nov-2013 07:00:00


Columns 4 through 5


04-Nov-2013 07:00:00 05-Nov-2013 07:00:00


Verify that the difference between successive datetime values is 24 hours.


dt = diff(t)


dt = 1x4 duration array
24:00:00 24:00:00 24:00:00 24:00:00


Integer Step Size


If you specify a step size in terms of an integer, it is interpreted as a number of 24-hour
days.


t = t1:1:t2


t = 1x5 datetime array
Columns 1 through 3


01-Nov-2013 08:00:00 02-Nov-2013 08:00:00 03-Nov-2013 07:00:00


Columns 4 through 5


04-Nov-2013 07:00:00 05-Nov-2013 07:00:00


Add Duration or Calendar Duration to Create Sequence of


Dates


This example shows how to add a duration or calendar duration to a datetime to create a
sequence of datetime values.


Generate Sequence of Dates and Time
Free download pdf