Trup
Trup

Reputation: 1655

Converting to matlab time

I have strings of the format '15:10:21' for time, and I also know the date, which is in the format 2011-08-05.

What's the best way to obtain matlab time (in days since 1900) out of this data?

Upvotes: 2

Views: 10347

Answers (1)

nibot
nibot

Reputation: 14928

Use datenum:

>> num = datenum('2011-08-05 15:10:21')

num =

   7.3472e+05

>> datestr(num)

ans =

05-Aug-2011 15:10:21

The "matlab time" is actually days since the 0th of January, in the year 0:

>> datestr(0)

ans =

00-Jan-0000

Upvotes: 5

Related Questions