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!

 채택된 답변

the cyclist
the cyclist 2012년 1월 16일

0 개 추천

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.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Time Series Objects에 대해 자세히 알아보기

태그

질문:

2012년 1월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by