how to mark the first and the last points on the plot

I could not have the value at the end point of the plot when I used the following code as an example:
plot(1:1:100,data(1:1:100));
set(gca,'XTick',1:10:100);
set(gca,'XTickLabel',0:1:9);
but I could not have first and last point value properly. How can I set them at the first and the last position well?
If you know anyone on my question, please let me know. Thank you.

Answers (1)

I don't fully understand your question or problem. Is this what you want?
plot(1:1:100,data(1:1:100));
set(gca,'XTick',0:10:100);
set(gca,'XTickLabel',0:1:10);
Update
plot(1:100,1:100);
set(gca,'XTick',1:10:101);
set(gca,'XTickLabel',0:1:10);
axis([0 110 0 110])

3 Comments

No, your way is not that I want. In my drawing, the first value is slightly parted from the left bottom of plot box, and the last value 10 is not appeared at the right bottom plot box. I tested your code but I found the same problem. Can you see my problem?
But thank you for your comment.
You do not get the 10 in your original code because your original code stops labeling at 9.
When I try Fangjun's code, I do get the 10 appearing.
To get the plot box to touch the outside of the plot, command
axis tight
To have 11 Xticks starting from 1, you will have to use 1:10:101, not 1:10:100.
You data range is from 1 to 100. The axis is set automatically so xlim is set at [1 100]. To show the Xtick of 101, you will need to use xlim() or axis() to set it properly. See update.

Sign in to comment.

Tags

Asked:

on 1 Dec 2011

Community Treasure Hunt

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

Start Hunting!