Time axis based on the last 24 hours
Show older comments
Hello everyone!
I am trying to find a way to make my axis go from a certain time to the same time 24h later. What I mean is that I am taking measurements for the last 24 hours and I want my axis to be limited and have certain ticks.
More specifically, I get measurements which start at 10am on the 1st of Nov and it finishes at 10am on the 2nd of Nov. And i want my axis to go from 10 to 24 / 00 to 10 with 1h steps (ticks).
Any suggestions on how to do that are more than welcome.
Thanks a lot for your time.
1 Comment
asdada
on 26 Oct 2016
Answers (1)
Walter Roberson
on 26 Oct 2016
If you have R2014b or later:
n = datetime()-hours(24);
x = n + hours(0:23);
plot(x, rand(1,24))
ax = gca; ax.XRuler.TickLabelFormat = 'HH'
(XRuler might not have been accessible until R2015a or R2015b)
Categories
Find more on Axis Labels 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!