How to create sequence datetime in matlab by specific duration

1 Ansicht (letzte 30 Tage)
I want to create a set of date time in this format datetime
date=('01/12/2016 00:15:00','InputFormat','dd/MM/yyyy HH:mm:ss')
from
if true
t1 = datetime('01/12/2016 00:15:00','InputFormat','dd/MM/yyyy HH:mm:ss');
t2 = datetime('31/12/2016 23:45:00','InputFormat','dd/MM/yyyy HH:mm:ss');
end
How to create sequence datetime in matlab by specific 15 mins interval from t1 to t2 ?
  1 Kommentar
Peter Perkins
Peter Perkins am 24 Jan. 2018
If those timestamp literals are actually supposed to represent text values that are read from a file or something, then those calls to datetime are probably fine. But ikf you have typed that, literally, in your code, you are likely better off using
datetime(2016,12,1,0,15,0)
datetime(2016,12,31,23,45,0)
You may find the text version easier to read, but noone reading the numeric version has to wonder if it's Dec 1st or Jan 12th.
Also, the numeric version often allows you to do things like
datetime(2016,12,1,0,15:15:1425,0)
although maybe in your case Fangjun's suggestion is simpler.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 24 Jan. 2018
t1:minutes(15):t2

Weitere Antworten (0)

Kategorien

Mehr zu Dates and Time finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by