如何在单击时找到点的索引并将其添加到数组、列表或向量的末尾?
h=figure;
image(result);
locx = [];
locy = [];
while (ishandle(h))
pos = get(0, 'PointerLocation');
locx(end + 1) = pos(1);
locy(end + 1) = pos(2);
pause(1);
end
虽然我只单击了两个点来查看它们的 x、y 和索引,但许多 x 位置已保存在 locx 数组中。请提出解决方案和修复:
locx =
Columns 1 through 16
635 1116 231 758 771 591 596 46 116 116 116 1362 852 498 1920 1663
Columns 17 through 32
733 795 795 1920 1895 1806 1061 700 123 1102 1097 1615 1 226 233 233
Columns 33 through 43
191 854 836 1920 1920 1920 1920 1920 1905 1189 1912