MATLAB Answers

Plot time on x axis for 24 hours duration

5 views (last 30 days)
NN
NN on 21 Nov 2020
Commented: Image Analyst on 21 Nov 2020
How can i plot my data against time on x axis which is 24 hours duration split every two hours.
Sample has been attached here.

  0 Comments

Sign in to comment.

Answers (1)

VBBV
VBBV on 21 Nov 2020
Edited: VBBV on 21 Nov 2020
%if true
T = hours(0:2:24)
TT = duration(T,'Format','hh:mm')
Rd = rand(13,1)
plot(TT,Rd)
xticks(TT);
xticklabels({'00:00','02:00','04:00','06:00','08:00','10:00','12:00','14:00','16:00','18:00','20:00','22:00','24:00'})
xtickangle(90)

  4 Comments

Show 1 older comment
NN
NN on 21 Nov 2020
when i plot the attached data , it shows the values as numbers and not as time.
NN
NN on 21 Nov 2020
Thank you ,
I am getting x axis as the required format ,but still how can i plot my data in time to the 24 hour format .
Kindly advice
Image Analyst
Image Analyst on 21 Nov 2020
You accepted this answer so everyone assumes that you got it figured out by now. If that's not true, then unaccept the answer and maybe someone will help by showing you how to use the xtickformat() function.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!