I get date info when plot a Datetime in x-axis.
Mostrar comentarios más antiguos
Hi, I am trying to plot a voltage data vs time data (HH:MN:SS) from a Datetime, but when I build the graph the x-axis always take the Year data (Dec 31, 1899).
I have tried modified the Datetime and the axis parameters, but always get this info.
How can I only display Hour:Minutes:Seconds? The year info is not important for me.
Thanks.

4 comentarios
the cyclist
el 2 de Abr. de 2021
Can you upload your data, or a small subset, so that we don't have to create out own dataset (which also might differ in some important way from yours).
Victor Olivero
el 4 de Abr. de 2021
Victor Olivero
el 4 de Abr. de 2021
Editada: dpb
el 5 de Abr. de 2021
dpb
el 5 de Abr. de 2021
Yes, that too. A MATLAB datetime doesn't exist without an associated date and time.
Unlike the venerable and deprecated datenum or an Excel date that are both represented as a julian date in a double where the whole portion of the value represents days and the non-integer part the fractional portion of a 24-hour day, the datetime is an object containing both a date and a time and the constructor for it will create a date from thin air if one isn't provided.
timeofday() does the equivalent conversion to a duration object as the alternative suggested -- the difference is the subtraction of the origin of the timeseries I suggested will give you a 0 origin irregardless of the actual time, timeofday will return the actual hours of the day of the datetime values.
Which is to use if not just the fixup of the display of the datae depends on situation.
Respuesta aceptada
Más respuestas (1)
Adam Danz
el 18 de Oct. de 2023
1 voto
Starting in MATLAB R2023b, use the xsecondarylabel function to set, change, or remove a secondary label.
For more info and a demo, see this Graphics and App Building blog article.
Categorías
Más información sobre Dates and Time en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!