convert day year hour data series with missing data to a serial number
Mostra commenti meno recenti
I have a year of data from "01/01/2003 00:00" to "2003/12/31 23:59" with some days/hous missing from the data series. I think to convert these dates/times to serial numbers I have to use the datenum. To convert each one of these numbers I understand that I have to do: datenum(2003,1,1,0,0,0) which gives ans =
731582.00
This is fine for one number but how I can convert the whole series? thanks, Katerina
Risposta accettata
Più risposte (1)
Adam
il 22 Ago 2014
str{1} = '01/01/2003 00:00'
str{2} = '2003/12/31 23:59'
datenum( str )
ans =
1.0e+05 *
7.3158
7.3195
So you should just be able to put all your strings into a cell array and pass that in to datenum
5 Commenti
I've never really used datanum, but it seems it doesn't mind if your array of strings is jumbled up with different formats either. I just pasted in the two dates from your question without realising they were in different formats!
Edit : Looking at the help I guess it is just slower with jumbled up format names that the Matlab function has to work out itself for each element. Putting them all in the same format and specifying that explicitly would be faster.
Katerina F
il 23 Ago 2014
Adam
il 23 Ago 2014
Is that all one string in a single variable?
Katerina F
il 25 Ago 2014
If it is a cell array you should just be able to pass it to datenum. If not then you will need to convert each row to a cell containing the string rather than a standard char matrix using e.g.
dateCells = cellstr( dates )
Categorie
Scopri di più su Time Series Objects in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!