hi
how can i select a point from a graph? i have a graph and i want to select a point from it and do some works with its coordinate(x & y). i want to select on graph and recieve x & y coordinate
thank u

1 件のコメント

Kavish Chaurasia
Kavish Chaurasia 2011 年 6 月 29 日
there is a tool to locate the coordinate on a particular graph, which could be seen as an icon on the graph window.

サインインしてコメントする。

 採用された回答

Gerd
Gerd 2011 年 6 月 28 日

2 投票

Hi Armin,
you can use datacursor mode.
In the callbackfunction you can play with the points (x & y ) received from the callback. If you do need an example leave me a note.
Gerd

1 件のコメント

Gerd
Gerd 2011 年 6 月 29 日
Hi Armin,
of course you can use a GUI to fulfill your requirements but you don't have to use one.
Here is short example:
x=linspace(0,10,1000);
y=sin(x);
plot(x,y)
dcm = datacursormode;
Now you can click into your figure and the x and y values are displayed.
If you want to calculate something with these values you can simply type
position = getCursorInfo(dcm);
in the command window and you have the answer of the position in the graph.
You can also use the callback function by typing
set(dcm,'UpdateFcn',{@myupdate})
Now the myupdate function is called everytime you click into your figure.
Please have a look at the documentation
help datacursormode
The command is well documented.
Gerd

サインインしてコメントする。

その他の回答 (1 件)

Gerd
Gerd 2011 年 6 月 29 日

0 投票

When you run your m-file and nothing is selected on the graph the position variable is empty. When your m-file is finished the position is stored and you can display the result in the command window. I would suggest to use the callback function so everytime you click on your figure you receive the position values.

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

製品

質問済み:

2011 年 6 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by