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

87 次查看(过去 30 天)
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.

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 中查找有关 Graphics Performance 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by