How to calculate series of values by specifying starting time using datenum????????

Hello,
kindly help to solve this issue
I just to want to find the serialdatenumber by specifying the start time and end time using datenum!!!!
%%%%%my code%%%%
starttime = datenum(2018,03,23,10,00,00)
endtime = datenum(2018,03,23,10,10,00)
tme = starttime:endtime
I just need to know how to calculate serialdatenumber for minutes,seconds,milliseconds from 10:00:00 to 10:10:00

 Accepted Answer

starttime = datenum(2018,03,23,10,00,00)
endtime = datenum(2018,03,23,10,10,00)
ms = 1/(24*60*60*1000);
tme = starttime:ms:endtime;
This will be 60001 elements long.

More Answers (1)

You need to specify a step size.
But you'll likely be much happier using datetimes:
>> starttime = datetime(2018,03,23,10,00,00)
starttime =
datetime
23-Mar-2018 10:00:00
>> endtime = datetime(2018,03,23,10,10,00)
endtime =
datetime
23-Mar-2018 10:10:00
>> starttime:minutes(2.5):endtime
ans =
1×5 datetime array
23-Mar-2018 10:00:00 23-Mar-2018 10:02:30 23-Mar-2018 10:05:00 23-Mar-2018 10:07:30 23-Mar-2018 10:10:00

5 Comments

Thank you Peter!!! But I tried this method also,but It didn't work for me
When I tried this on my command window,what I got is
Starttime =datetime(2018,03,23,10,00,10)
Undefined function 'datetime' for input arguments of type 'double'
Did you mean:
Starttime =date2time(2018,03,23,10,00,00)
For this also it's giving
Error using date2time
Too many input arguments
datetime() was added in R2013b. Which release are you using?
I misremembered: datetime() was added in R2014b.

Sign in to comment.

Asked:

on 27 Mar 2018

Commented:

on 28 Mar 2018

Community Treasure Hunt

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

Start Hunting!