Returning the "column" number of a Button Down function on an image (GUIDE)

1 次查看(过去 30 天)
Hello. I have an image loaded onto an axes component in GUIDe and I want the mouse location over the squares to drive an xystage to a positon
All I need to return is which column is selected when the mouse if over a particular square: i.e just considering 1D (i.e. columns), if after pressing the mouse, the x coordinate is between 13 & 39, then report column1 (or just 1). If the x coordinate is between 88 and 114, then report back 3. In reality I have 12 columns so am looking a) for the best way to do this, and b) the best way to define the edges (the values of which I have)
This is my mouse click function
function mouse3Callback(src, eventData)
handles = guidata(src);
axesHandle=get(src,'Parent'); %Object handle is the image
xyz=get(axesHandle,'CurrentPoint');
x = round(xyz(1,1))
y = round(xyz(1,2))
that I assign to the axes holding the image (axes3) Button down fucntion:
set(handles.axes3, 'ButtonDownFcn', @mouse3Callback),
Thnaks for any help
  1 个评论
Jason
Jason 2020-1-15
i've come with this, maybe there is a better way:
LE=[15,62,109,157,204,251,298,345,391,438,484,531] %Left egde
RE=LE+32 %Right Edge
col=0;
for i=1:12
if (x>LE(i)&&x<RE(i))
col=i
end
end
col
set(handles.editPt,'String',num2str(col))

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by