여기에 가장 우아하게 그 방법은 다음과 같습니다
는
function test
% create test figure
f = figure(1);
% set function to call on mouse click
set(f, 'WindowButtonDownFcn', @clicker);
end
% function called on mouse click in the figure
function clicker(h,~)
get(h, 'selectiontype')
% 'normal' for left moue button
% 'alt' for right mouse button
% 'extend' for middle mouse button
% 'open' on double click
get(h, 'currentpoint')
% Current mouse location, in pixels from the lower left.
% When the units of the figure are 'normalized', the
% coordinates will be [0 0] inb lower left, and [1 1] in
% the upper right.
end
"그래프가 그려져 있지 않으면 어떻게합니까?"라고 묻는다면 명확하지 않습니다. 하지만 아마 ginput()을 사용하고 싶을 것이다. 예 : 여기를 참조하십시오 : [get-pixel-coordinates-efficient-in-matlab] (http://stackoverflow.com/questions/6541444/getting-pixel-coordinates-efficiently-in-matlab) – Justin
어딘가에 빈을 클릭하고 싶습니다. 플롯 (그림 (1)은 실제로 그래프가 나타나는 흰색 캔버스를 생성하지 않기 때문에 matlab은이를 축이라고 부릅니다.) Axes의 x와 y 좌표의 최대/최소 한계를 미리 정의하고 축의 빈 영역을 클릭하면 변수의 x와 y 좌표를 저장할 수 있습니다. – user13267
다음을 사용할 수 있습니다. 콜백. – bonCodigo