How Can i get MATLAB to plot date on x-axis?
Show older comments
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)
Star Strider
on 14 Feb 2018
0 votes
Peter Perkins
on 15 Feb 2018
Since R2014b:
d = datetime(2015,9,1,0:6:17544,0,0);
x = cumsum(randn(size(d)));
plot(d,x)

3 Comments
Ayomide Olabode
on 12 Oct 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?

Star Strider
on 13 Oct 2019
Post this as a new Question. It is not an Answer to the posted Question in this thread.
Geletaw Behailu
on 26 Mar 2020
I have the same question as Ayomide Olabode , I need the way how to plot as shown in his question above
Categories
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!