How can I control xticklabel?

조회 수: 1 (최근 30일)
Riyadh Muttaleb
Riyadh Muttaleb 2016년 12월 15일
댓글: Walter Roberson 2016년 12월 15일
Hello All,
I have serial of datenum on X-axis, I would like to show in my plot that the first datetick is the first datenum number and the end is the end of datenum number.
please any one could help me?
Thanks in advance
Riyadh

답변 (1개)

Walter Roberson
Walter Roberson 2016년 12월 15일
That would happen automatically.
x = datenum('Jan 17, 2016') : datenum('Jan 23, 2016');
y = mod(x, 4);
plot(x,y);
If the difficulty is with it automatically putting the label in scientific notation then:
In R2015a or later (might need R2015b):
ax = gca;
ax.XAxis.Exponent = 0;
In earlier versions (including R2014b, which did not have the Numeric Ruler properties yet even though it was HG2):
set(gca,'XTickLabel', cellstr( num2str( reshape(get(gca,'XTick'),[],1) ) ) )
  댓글 수: 2
Riyadh Muttaleb
Riyadh Muttaleb 2016년 12월 15일
Thank you for your response, this works, but what I have is "time=datenum(T(:,1:6))" for x-axis, so I don;t know why the first and last are not the same value in the serial date?
Walter Roberson
Walter Roberson 2016년 12월 15일
Could you give some sample data? I get the impression that your T might contain date vectors, something like an array of [2016 12 14 19 48 18.5665000000008] ?

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

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by