How can I find mouse position on axes image?

4 次查看(过去 30 天)
Hi, I read an image in Axes object GUI. And After I want to find mouse(x,y) coordinate on axes image.( Mousemove event) Thanks

回答(1 个)

Star Strider
Star Strider 2016-1-15
See if one of the mouse utilities in the File Exchange will do what you want.
  1 个评论
Mike Garrity
Mike Garrity 2016-1-15
get(gca,'CurrentPoint')
It returns a 2x3 array because the axes actually shows a 3D volume. The first row is the point at the back of the volume, while the second row is the point at the front of the volume. In 2D the X & Y will be the same for both rows, you can just take the 1st row like this:
cpt = get(gca,'CurrentPoint')
pt = cpt(1,1:2)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by