X-axis: Construct with hourly respect
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
HI I'm trying to construct a x-axis with respect to hours. My codes can be seen below but I'm trying to construct an 24-hour on the x-axis that is from 12:00 (today) to 12:00 (tomorrow); that is counting from 12, 13, 14, 15,..., 9, 10, 11, 12. Can you help?
startdate = datenum('12','HH');
enddate = datenum('12','HH');
dt = linspace(startdate,enddate,24);
data = [1,42,5,3,2,6,77,8,3,5,12,5,84,45,23,64,23,74,784,45,74,5,3,2]; %random data
plot(dt,data)
hold on
datetick('x','yyyy','keepticks');
0 commentaires
Réponse acceptée
Walter Roberson
le 16 Jan 2013
enddate = startdate + 1;
otherwise your start and end date end up being the same.
dt = linspace(startdate, enddate, 25);
Notice the 25 instead of 24.
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 -> 12 entries
00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12 -> 13 entries
total 25, not 24.
and
datetick('x', 'HH')
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Type Conversion 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!