X-axis: Construct with hourly respect

2 ビュー (過去 30 日間)
Lily
Lily 2013 年 1 月 16 日
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');

採用された回答

Walter Roberson
Walter Roberson 2013 年 1 月 16 日
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 件のコメント
Lily
Lily 2013 年 1 月 18 日
Thx for this hint... It's looks so simple when you think of it like this :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by