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! :)

Answers (2)

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

3 Comments

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
Post this as a new Question. It is not an Answer to the posted Question in this thread.
I have the same question as Ayomide Olabode , I need the way how to plot as shown in his question above

Sign in to comment.

Categories

Tags

Asked:

on 14 Feb 2018

Commented:

on 26 Mar 2020

Community Treasure Hunt

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

Start Hunting!