how to use function handle
4 views (last 30 days)
I have a function boop:
Now I want that whenever I move my mouse over a figure, the function will display 'hello world', How do i have to set the function? :
None of the above is working.
Guillaume on 20 Aug 2015
This should work:
set(gcf, 'windowButtonMotionFcn', @(~, ~) boop('hello world'));
A UI callback always receives two arguments (an object handle and some event data), which you need to accept. I've done that above by creating an anonymous function that accepts and ignores these two arguments (the @(~, ~)) and then simply call your handle with the correct argument.
See the doc for more details.
More Answers (1)
Morteza on 20 Aug 2015
if you are using the GUI of Matlab in the figure-Ispector find the WindowsButtonMotionFcn and create its function then pregame it like as you want. like bellow:
function figure1_WindowButtonMotionFcn(hObject, eventdata, handles)