getting x values by clicking on axes

Hi all!
I have the set of (x,y) data:
x=[4 10 25 30 37 45 58 77 81 89 93 100 113 122 130 137 145 152 160 163]; y=[15 24 7 45 35 58 71 22 64 10 21 35 67 50 59 63 77 43 40 5];
After plotting it, I want to be able to get x values in t vector by clicking on the axes.
How can i do it?

2 Comments

Why clicking on the axes? Why not by clicking on the curve?
Search for "Data Cursor" in the on-line help.
Thanks, I'll try.

Sign in to comment.

Answers (2)

Click on your plot the add this code
x=get(gco,'xdata')
y=get(gco,'ydata')

15 Comments

You should click on the plot, not near the plot
Please, add a comment (click on comment this answer) instead of answer.
What do you mean by "I need to fix N data "
Thanks for your recommendations))) (I'm beginner here)
I mean the following: We have (x,y) data set. I plot it in the graph. After that I want by clicking on the x axis to fix, for example, 5 points in the t vector...
You can use the figure editor:
On the top of your figure click on edit, then choose figure properties. Select your plot (click on your plot) then click on more properties, change the xdata and ydata
But I want to program it in the m.file, because on the base of this function I write a program, where I should use the created t vector...
Then use
y=get(gco,'ydata')
to change the first values of y use
y(1:5)=[2 4 5 7 1]
set(gco,'ydata',y)
OK, thanks so much.
If I will have any more question later, can I write you here?
If the answer helps , mark it as accepted, then post a new question, not here.
How can I attach my graphic, to explain you my problem?
Please post a new question, not here!
But it's not a new question... But How can I attach an image here?
Upload your image to a hosting website, then show the link
Can I send you the file by e-mail? (I upload it here, but it says that it can take a few days to show on this site)
Please, check your e-mail.

Sign in to comment.

Haykush
Haykush on 4 May 2013
First of all, thanks so much for your attention.
For example, I need to fix N data by clicking to the x axis. What do you suggest to do in this case?
Thanks in advance.

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Asked:

on 4 May 2013

Community Treasure Hunt

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

Start Hunting!