How can I convert datetime into double?
387 visualizzazioni (ultimi 30 giorni)
I have a data which is 60 x 4320 datetime, each cell is 2019/01/01 00:00:00 and want to convert this into 60 x 4320 double.
I tried to use datevec(data) but it resulted 259200 x 6 double, one row one character, like
2019 01 01 00 00 00
2019 01 01 00 10 00
2019 01 01 00 20 00
galaxy il 12 Dic 2019
You can use datenum to convert each your data to double.
>> t = datetime('now')
>> DateNumber = datenum(t)
After that, if you want to convert back:
hope it helps
Eric Sofen il 13 Dic 2019
What do you want the doubles to represent?
Datenum returns a double represents days since 0 CE.
The posixtime function would give you a double representing seconds since the Unix epoch (00:00:00 1-Jan-1970 UTC).
The juliandate function gives a double representing days since...
The trouble with using double to represent dates and times is that there isn't one definition (there are also precision-related issues over long spans of time).
I'm curious if you'd be willing to share what you want to do with the doubles, and why you can't do it using datetime?