Textscan won't read the dates with spaces
Mostrar comentarios más antiguos
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 comentario
per isakson
el 15 de Ag. de 2017
Editada: per isakson
el 17 de Ag. de 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.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Dates and Time en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!