Variable 'data' does not update in main script

1 view (last 30 days)
I am working on acquiring mouse cursor data on matlab. Function 'mouseMove' is create for this purpose. function is working very well and current mouse cursor value is also retrieve. but I want to acquire that cursor value on main script which is update as the mouse move. But problem is that mouse cursor value in variable 'data' which is calling the function , is not updating the values as the cursor move
This my main code/script.
%%For single image
img = imread('pic.jpg'); %Read the image
imshow(img); % Show the image
temp = @mouseMove; % Create Function Handle
set (gcf, 'WindowButtonMotionFcn', temp); % Data map on plot figure
data = temp() % Acquire the mouse cursor data
this my function
function result = mouseMove (object, eventdata)
result = get (gca, 'CurrentPoint');
title(gca, ['(X,Y) = (', num2str(result(1,1)), ', ',num2str(result(1,2)), ')']);
end

Answers (0)

Categories

Find more on Graphics Object Properties 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!