plotting values with duration format

조회 수: 3 (최근 30일)
sermet
sermet 2017년 9월 7일
댓글: sermet 2017년 9월 7일
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.

채택된 답변

KL
KL 2017년 9월 7일
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
sermet
sermet 2017년 9월 7일
2015a
sermet
sermet 2017년 9월 7일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by