MATLAB Answers

The problem on getting x,y coordinate value of an image when clicking mouse

1 view (last 30 days)
Ben Lu
Ben Lu on 15 Aug 2017
Edited: KSSV on 16 Aug 2017
The code is below. main function and callback function are different files. So how to transfer the x, y value in the callback function to the main function.
% main function
function test_mouse_track()
figure;
axis([-10,10,0,5]);
set(gcf,'WindowButtonDownFcn',@ButttonDownFcn);
% callback function
function ButttonDownFcn(src,event)
pt = get(gca,'CurrentPoint');
x = pt(1,1);
y = pt(1,2);
fprintf('x=%f,y=%f\n',x,y);

  0 Comments

Sign in to comment.

Answers (0)

Sign in to answer this question.