How do I turn date time into text
Mostrar comentarios más antiguos
Hi, I need to use the text command to inset a date time into an image. Text only takes strings. I can't figure out how to make the current date time that I have computed into a text. Can you please help me?
specifically see below.
time_now=datetime(2017,7,23,7,48,04+dec_time); (assume dec_time is a counter that increments inside a loop.
fooim=figure;
imagesc(foo,clims); % all this is doing is making an image that I am interested in
colormap(gray)
text(200,200,time_now) % I want to put the date time I have calculated above into the image
thanks
Geoff
1 comentario
Matthew McHarg
el 22 de Ag. de 2016
Respuestas (2)
Walter Roberson
el 22 de Ag. de 2016
1 voto
char() the datetime object after having set its Format property.
Matthew McHarg
el 23 de Ag. de 2016
0 votos
1 comentario
Peter Perkins
el 23 de Ag. de 2016
datestr is not recommended, it's intended for backwards compatibility, and uses the older formatting "language". If you need a text representation of a datetime, recommended way is to use use char, as Walter suggests.
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!