How can I plot my data corresponding specified x-axis value?

I have 15 values which are corresponding 15 specified numbers. I want to plot y but i can't change x-axis values.Matlab automatically sets the x-axis. For example;
y=[1.5 2.5 3.5 4.5]; x=[0.2 1.5 3.5 7.4]; plot(x,y,'.-');
I tried "set","xticklabel" and other things but I did not succeed. How can I solve this problem? How can I plot y which is corresponding each value of x?

답변 (2개)

Walter Roberson
Walter Roberson 2014년 4월 18일

0 개 추천

You can use xlim() to control the x axis range.
I do not think I understand why you consider plot(x,y,'-') to not be plotting the y that corresponds to each value of x ?
mehmet
mehmet 2014년 4월 18일
편집: mehmet 2014년 4월 18일

0 개 추천

Thanks for your respond,
I know that When I plot(x,y),It's plotting the y that correspond to each value of x. But i can't see my values of matrix of x on the figure. I tried to use xlim and set(.,.,, )but i can't see specified value of x on the figure. Values of x automatically are setted.I read lots of document about this topic in this website and also I used matlab's help icon but can't fix the problem.
Could you please give me an example how can I handle it?

댓글 수: 1

text(x+0.1, y, cellstr(num2str(x(:)) )
would label each point with its x coordinate, if that's the sort of thing you want.
Perhaps you want
set(gca, 'Xtick', x)

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

카테고리

도움말 센터File Exchange에서 Axis Labels에 대해 자세히 알아보기

질문:

2014년 4월 18일

댓글:

2014년 4월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by