Textscan won't read the dates with spaces
Afficher commentaires plus anciens
Textscan doesn't work when date elements are separated by spaces. However the same format works when used with datetime function. Have a look at the following code:
textscan('1959 05 21','%{yyyy MM dd}D') % Doesn't work when there are spaces
datetime('now','Format','yyyy MM dd') % same format works with datetime function
textscan('1959-05-21','%{yyyy-MM-dd}D') % Works when when space is replaced with non letter character
textscan('1959 05 21','%{yyyy MM dd}D','whitespace','') % Works when whitespace is set to none
textscan('1959 05 21 567','%{yyyy MM dd}D%d','whitespace','') % Doesn't work
How can I make last line of the code to work?
Thanks
PS: Read Walter Roberson and per isakson's comments on the accepted answer
1 commentaire
per isakson
le 15 Août 2017
Modifié(e) : per isakson
le 17 Août 2017
"How can I make last line of the code to work?" I don't think it's possible. It seems that Matlab cannot handle the double use of space, as part of the date format and at the same time as list separator before the integer.
I assume that your problem is not to parse the string, but to find the limits of textscan.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Dates and Time dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!