필터 지우기
필터 지우기

adjusting of axis X

조회 수: 1 (최근 30일)
Matus
Matus 2013년 6월 19일
Hi,
I have two row vetctors
a=[1.1 1.8 2.3 3.1 4.5 5.7 6.1 7];
b=[2 5 3 8 9 1 5 2];
plot(a,b)
When I make a plot, there arent values 1.1 1.8 2.3 3.1 4.5 5.7 6.1 7 on the axis X but there are 1 2 3 4 5 6 7. Is it possible to dispaly 1.1 1.8 2.3 3.1 4.5 5.7 6.1 7 on the axis X?
Thank you.

채택된 답변

Hugo
Hugo 2013년 6월 19일
Yes it is!
First you need to make a vector b with the labels:
b=arrayfun(@(x)num2str(x),a,'UniformOutput',false);
Then,
set(gca,'XTick',a,'XTickLabel',b);
should do the trick. If you have the handle of the axis, just replace gca with that handle.
  댓글 수: 1
Jan
Jan 2013년 6월 19일
Setting the XTicks is enough:
set(gca, 'XTick', a);
Then Matlab creates the correct labels automatically.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Visual Exploration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by