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

조회 수: 2 (최근 30일)
Jason
Jason 2020년 1월 15일
댓글: Jason 2020년 1월 15일
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