MATLAB Answers

Plot time on x axis for 24 hours duration

22 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.

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

Translated by