How to change the values of X axis and Y axis?
120 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
UJJWAL
on 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
0 Comments
More Answers (2)
Jessica Beltran
on 13 Oct 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.
1 Comment
the cyclist
on 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
0 Comments
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!