How to create sequence datetime in matlab by specific duration

1 次查看(过去 30 天)
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 个评论
Peter Perkins
Peter Perkins 2018-1-24
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.

请先登录,再进行评论。

采纳的回答

Fangjun Jiang
Fangjun Jiang 2018-1-24
t1:minutes(15):t2

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by