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

94 Ansichten (letzte 30 Tage)
Alan
Alan am 26 Sep. 2011
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

Akzeptierte Antwort

UJJWAL
UJJWAL am 26 Sep. 2011
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

Weitere Antworten (2)

Jessica Beltran
Jessica Beltran am 13 Okt. 2011
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 am 26 Sep. 2011
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

Kategorien

Mehr zu Graphics Performance finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by