X-axis: Construct with hourly respect

2 Ansichten (letzte 30 Tage)
Lily
Lily am 16 Jan. 2013
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');

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 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')
  1 Kommentar
Lily
Lily am 18 Jan. 2013
Thx for this hint... It's looks so simple when you think of it like this :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by