vector of decimal day

Is it possible to create a vector of decimal days?
I want to generate a time vector which starts and ends at specific dates and has an interval of 4 minutes between each time (in decimal day). For example: start on the first of jan 2009 and end on the 30th of April 2009 with a time stamp of 4 minutes between each time stamp!

 Respuesta aceptada

the cyclist
the cyclist el 16 de En. de 2012

0 votos

Here is one of many possible ways.
HOURSPERDAY = 24;
MINUTESPERHOUR = 60;
MINUTESPERDAY = HOURSPERDAY * MINUTESPERHOUR;
firstDate = '2009-01-01';
lastDate = '2009-04-01';
firstDatenum = datenum(firstDate,'yyyy-mm-dd');
lastDatenum = datenum(lastDate, 'yyyy-mm-dd');
fourMinuteDatenumVector = (firstDatenum:4/MINUTESPERDAY:lastDatenum)';
fourMinuteTimestampVector = datestr(fourMinuteDatenumVector);
I wasn't quite clear on how you wanted the output. The variable fourMinuteDatenumVector is a MATLAB datenum format. The variable fourMinuteTimestampVector is a timestamp format. You can use the datestr() function to convert to many different formats.

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

el 16 de En. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by