MATLAB Answers

Raldi
0

Pass variables into set(frt,'W​indowButto​nDownFcn',​@mousePos)

Asked by Raldi
on 15 Jul 2012
Quick question, how can i pass some other variables that i want in mousePos
function mousePos(hObject,~)
mPos=get(hObject,'CurrentPoint');
finalPos(mPos,data)
The data variable is defined in the main function but i want to use it here too.

  0 Comments

Sign in to comment.

Products

2 Answers

Answer by Walter Roberson
on 15 Jul 2012
Edited by Walter Roberson
on 15 Jul 2012
 Accepted Answer

set(frt, 'WindowButtonDownFcn', {@mousePos, data} )
and
function mousePos(hObject, ~, data)
Note: this will use the value of "data" as of the time the callback is created, and will not reflect any updates to "data" that are made after that.

  3 Comments

Thanks, i'll find a way to update it later.
Another thing, i was trying to save each rectangle i created so later on i can have acces to the position of the one i want. The code below is not working though.
for i = 1:compnum
id = [num2str(i)];
h.id = imrect(gca, compdata(i,:));
daspect([1,1,1])
end

Sign in to comment.


Answer by Xiangqi
on 27 Aug 2013

To Raldi,
Hi~ Have you found the way to update the value of "data" ?
I encountered the same problem and don't know how to update it.
Thanks for your help in advance.
Huang

  0 Comments

Sign in to comment.