今天,将介绍GUI中获取图像坐标的最后一种方法—通过axes坐标轴的回调函数实现坐标的获取。
今天使用的回调函数是axes中的ButtonDownFcn函数,当鼠标在axes中点击时,MATLAB就会调用ButtonDownFcn函数。
下面是该GUI的gif图:
下面贴出实现代码:
function varargout = Getposition3(varargin)
% GETPOSITION3 MATLAB code for Getposition3.fig
% GETPOSITION3, by itself, creates a new GETPOSITION3 or raises the existing
% singleton*.
%
% H = GETPOSITION3 returns the handle to a new GETPOSITION3 or the handle to
% the existing singleton*.
%
% GETPOSITION3('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GETPOSITION3.M with the given input arguments.
%
% GETPOSITION3('Property','Value',...) creates a new GETPOSITION3 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Getposition3_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Getposition3_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help Getposition3
% Last Modified