How Can i get MATLAB to plot date on x-axis?

Hey, I have an issue concerning getting MATLAB to plot dates on X-axis.
my time matrix is a 2924x1 matrix representing hours since start, with 6 hours intervalls. So: t=[6, 12, 18, 24, ..., 17544]. My starting time is [2015, 9, 1] (sep.1.2015) at 0600.
If someone could help me getting MATLAB to plot dates on the x-axis instead of numbers up to 17544, that would be very helpful.
Thx! :)

Respuestas (2)

Star Strider
Star Strider el 14 de Feb. de 2018

0 votos

If you have R2014b or later, consider using a datetime (link) array. You can also use the datetick (link) function.
Peter Perkins
Peter Perkins el 15 de Feb. de 2018
Since R2014b:
d = datetime(2015,9,1,0:6:17544,0,0);
x = cumsum(randn(size(d)));
plot(d,x)

3 comentarios

Ayomide Olabode
Ayomide Olabode el 12 de Oct. de 2019
In my case, I need to have both the hour (from hour 0 to 24) and date show for each day. Can you help please?1.png
Star Strider
Star Strider el 13 de Oct. de 2019
Post this as a new Question. It is not an Answer to the posted Question in this thread.
Geletaw Behailu
Geletaw Behailu el 26 de Mzo. de 2020
I have the same question as Ayomide Olabode , I need the way how to plot as shown in his question above

Iniciar sesión para comentar.

Categorías

Etiquetas

Preguntada:

el 14 de Feb. de 2018

Comentada:

el 26 de Mzo. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by