Date and Time from Text with Literal Characters, Part 3
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
alpedhuez
el 6 de Dic. de 2020
Comentada: alpedhuez
el 7 de Dic. de 2020
To follow up with https://www.mathworks.com/matlabcentral/answers/683318-date-and-time-from-text-with-literal-characters-part-2?s_tid=srchtitle
The data is like
Date Visitors
'Jan 1 2020' 100
'Jan 2 2020' 50
I now want to create a new variable 'date' and set the value of the second row to be 1/1/2020, and then increment one by one. How can one let Matlab do this?
0 comentarios
Respuesta aceptada
Cris LaPierre
el 7 de Dic. de 2020
Editada: Cris LaPierre
el 7 de Dic. de 2020
date1 = datetime('Jan 1 2020','InputFormat', 'MMM dd uuuu','Format','M/d/yy');
date2 = datetime('Jan 5 2020','InputFormat', 'MMM dd uuuu','Format','M/d/yy');
date = date1:days(1):date2
Or if you know the number of rows but not the end date:
date = date1 + days(0:4)
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Calendar en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!