필터 지우기
필터 지우기

How to change the values of X axis and Y axis?

조회 수: 63 (최근 30일)
Alan
Alan 2011년 9월 26일
I want to change the values of X axis and Y axis when I plot a Graph, i.e, put the correct numbers instead of the matrix points. thanks

채택된 답변

UJJWAL
UJJWAL 2011년 9월 26일
Hi, I was not able to get your question clearly. Is this what you are asking ?
t = 0:0.01:2;
y= sin(t);
figure(1);
plot(y)
figure(2);
plot(t,y);
In the above code plot(y) will plot y with respect to the matrix points that is the matrix indices. The second plot that is plot(t,y) will plot it with respect to the corresponding values in t and you will see the actual numbers on the x-axis. Is that what you are asking ??
Happy To Help
UJJWAL

추가 답변 (2개)

Jessica Beltran
Jessica Beltran 2011년 10월 13일
Well, this may work for you.
If you have for example:
x = [1 2 3 4 5 6 7 8 9 10]; y=[.1 3 4 .2 5 1 7 3 1 0];
And you want to be able to manipulate the x-axis as you like, you can do this:
set(gca,'XTick',[1 5 9 10] ); %This are going to be the only values affected.
Then..
set(gca,'XTickLabel',[4 8 15 21] ); %This is what it's going to appear in those places.
  댓글 수: 1
Jessica Beltran
Jessica Beltran 2011년 10월 13일
I forgot to put plot(x,y) before the set

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


the cyclist
the cyclist 2011년 9월 26일
I'm not sure I understand what you want, so you might want to provide more specific detail. But I think you can do what you want by setting the 'XTick' and 'YTick' properties of the plot.
>> set(gca,'XTick', ... )
where you fill in a vector with the values you want in place of "...".
You might want to read "help get" and "help set" and this page about handle graphics: http://www.mathworks.com/help/techdoc/learn_matlab/f3-15974.html

카테고리

Help CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by