plotting values with duration format

7 views (last 30 days)
sermet
sermet on 7 Sep 2017
Commented: sermet on 7 Sep 2017
time_array=[6 0 0;6 1 0;6 2 0;6 3 0;6 4 0;6 5 0;6 6 0;6 7 0;6 8 0;6 9 0;6 10 0;6 11 0;6 12 0;6 13 0;6 14 0;6 15 0;6 16 0;6 17 0;6 18 0;6 19 0;6 20 0;6 21 0;6 22 0;6 23 0;7 0 0];
time_format=duration(time_array,'Format','hh:mm:ss');
data=[1.37;1.4;1.8;1.3;1.35;1.31;1.2;1;1.26;1.32;1.45;1.35;1.14;1.3;1.35;1.6;1.39;1.37;1.6;1.26;1.34;1.46;1.41;1.3;1.37];
figure(1)
plot(time_format,data,'c','LineWidth',1.75)
In the figure1, values of time_format cannot match the time_format array. How can I keep the exact value of time_format while plotting?
time format consists of day-hour-minute values. I cannot find day-hour-minute format in matlab. So in figure1, some values like 06:40:00 shouldn't be seen.

Accepted Answer

KL
KL on 7 Sep 2017
Because you have a jump from 06:23:00 to 07:00:00. Add the following line to your code and set the xticks explicitly.
xticks([time_format(1) time_format(6) time_format(11) time_format(15) time_format(20) time_format(25)])
  4 Comments
sermet
sermet on 7 Sep 2017
this time, I received; error using set While setting the 'XTick' property of Axes: Value must be a vector of type single or double whose values increase

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!