Borrar filtros
Borrar filtros

How to create sequence datetime in matlab by specific duration

2 visualizaciones (últimos 30 días)
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 comentario
Peter Perkins
Peter Perkins el 24 de En. de 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.

Iniciar sesión para comentar.

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 24 de En. de 2018
t1:minutes(15):t2

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by