how to convert hours to 'yyyy-MM-dd hh:mm:ss' format?
40 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have time in hours from 0-72 hours (i.e. 0, 1, 2, 3,..., 72). i.e. a = 0:72;
I would like to convert this hours into datestr with 'yyyy-MM-dd hh:mm:ss' format.
I know initial yyyy-MM-dd i.e. 2012-04-24.
So how can i set my output in 'yyyy-MM-dd hh:mm:ss' format?
I want o/p to be like;
2012-04-24 00:00:00, 2012-04-24 01:00:00, ...., 2012-04-25 00:00:00, 2012-04-25 01:00:00, ...., 2012-04-26 00:00:00, 2012-04-26 01:00:00
date should change with each 24 hours.
Any help will be greatly appriciated.
0 commentaires
Réponse acceptée
Stephen23
le 15 Juil 2022
dtm = datetime(2012,4,24,'Format','yyyy-MM-dd HH:mm:ss') + hours(0:72).'
4 commentaires
Steven Lord
le 15 Juil 2022
I want to put xticklabels.
If you're plotting using this datetime data as one of the inputs in your call to plot, the tick labels will automatically be generated from the plotted datetime array. You don't need to convert to a string array in this case.
v = 0:10;
x = datetime('today') + days(v);
y = v.^2;
plot(x, y)
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Dates and Time dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!