필터 지우기
필터 지우기

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