X-axis: Construct with hourly respect

2 visualizaciones (últimos 30 días)
Lily
Lily el 16 de En. de 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');

Respuesta aceptada

Walter Roberson
Walter Roberson el 16 de En. de 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 comentario
Lily
Lily el 18 de En. de 2013
Thx for this hint... It's looks so simple when you think of it like this :)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by