How can I find mouse position on axes image?

15 views (last 30 days)
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

Answers (1)

Star Strider
Star Strider on 15 Jan 2016
See if one of the mouse utilities in the File Exchange will do what you want.
  1 Comment
Mike Garrity
Mike Garrity on 15 Jan 2016
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)

Sign in to comment.

Categories

Find more on Visual Exploration in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!