Problems with converting date strings to date numbers
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dear all!
Any pointers as to what might be going wrong here would be much appreciated:
Error using dtstr2dtvecmx Failed on converting date string to date number.
Error in datevec (line 117) y = dtstr2dtvecmx(t,icu_dtformat);
Error in day (line 39) c = datevec(d(:),f);
I'm using Matlab 2015b (but have same error on 2013a). I should also have all the required toolboxes installed. And copying the function datenum into the folder doesn't solve the problem either.
I'm not sure where this is going wrong.
Many thanks for your help, Alex
4 commentaires
dpb
le 9 Déc 2015
" I'm not sure I can provide you with values for d and f"
Why not? What prevents you from doing as Stephen suggests and displaying the values for the function when it errors?
"What I have done is to copy-paste datenum into folder with the code."
There's no advantage in doing such things; there's a serious disadvantage in that one can thereby accidentally damage the distributed code by accidentally overwriting the original or somesuch.
Again, show us the data and the actual code line used to execute the call; the error indicates there's an issue there in that the input string has an invalid character so there's a good chance your assumption the read is ok isn't...
Stephen23
le 9 Déc 2015
Modifié(e) : Stephen23
le 9 Déc 2015
Copying datenum serves no obvious purpose, and could even cause major problems. Many inbuilt (and even third-party) MATLAB functions utilize sub-functions located in private directories that are only accessible to the function in its original location. By moving such a function you run the risk of making it useless because it can no longer access those sub-functions.
Réponses (1)
Kelly Kearney
le 9 Déc 2015
Usually this type of error appears when one of your input datestrings does not match the input format you specified. For example:
datenum('01/ab/2015', 'mm/dd/yyyy')
Error using datenum (line 178)
DATENUM failed.
Caused by:
Error using dtstr2dtnummx
Failed on converting date string to date number.
If your dataset is small enough, you may be able to find the culprit by just scanning manually. Otherwise, you may need to loop through your data in smaller chunks and see where the problem is. Unfortunately, datenum takes an all-or-nothing approach... if a single point is mis-formatted, it will fail.
0 commentaires
Voir également
Catégories
En savoir plus sur Time Series Objects dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!