matlabGUIcallback函数实现

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

搞了一下午,看了些资料,终于弄好了matlab GUI中的回调函数。

效果图见底部~
umtitled3.m:
[cpp]
1.function varargout = untitled3(varargin)
2.% UNTITLED3 M-file for untitled
3.fig
3.% UNTITLED3, by itself, creates a new UNTITLED3 or raises the existing
4.% singleton*.
5.%
6.% H = UNTITLED3 returns the handle to a new UNTITLED3 or the handle to
7.% the existing singleton*.
8.%
9.% UNTITLED3('CALLBACK',hObject,eventData,handles,...) calls the local
10.% function named CALLBACK in UNTITLED3.M with the given input arguments.
11.%
12.% UNTITLED3('Property','Value',...) creates a new UNTITLED3 or raises the
13.% existing singleton*. Starting from the left, property value pairs are
14.% applied to the GUI before untitled3_OpeningFunction gets called. An
15.% unrecognized property name or invalid value makes property application
16.% stop. All inputs are passed to untitled3_OpeningFcn via varargin.
17.%
18.% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
19.% instance to run (singleton)".
20.%
21.% See also: GUIDE, GUIDATA, GUIHANDLES
22.
23.% Copyright 2002-2003 The MathWorks, Inc.
24.
25.% Edit the above text to modify the response to help untitled3
26.
27.% Last Modified by GUIDE v2.5 18-Mar-2012 16:58:53
28.
29.% Begin initialization code - DO NOT EDIT
30.gui_Singleton = 1;
31.gui_State = struct('gui_Name', mfilename, ...
32.'gui_Singleton', gui_Singleton, ...
33.'gui_OpeningFcn', @untitled3_OpeningFcn, ...
34.'gui_OutputFcn', @untitled3_OutputFcn, ...
35.'gui_LayoutFcn', [] , ...
36.'gui_Callback', []);
37.if nargin && ischar(varargin{1})
38. gui_State.gui_Callback = str2func(varargin{1});
39.end
40.
41.if nargout
42. [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
43.else
44. gui_mainfcn(gui_State, varargin{:});
45.end
46.% End initialization code - DO NOT EDIT
47.
48.
49.% --- Executes just before untitled3 is made visible.
50.function untitled3_OpeningFcn(hObject, eventdata, handles, varargin)
51.% This function has no output args, see OutputFcn.
52.% hObject handle to figure
53.% eventdata reserved - to be defined in a future version of MATLAB
54.% handles structure with handles and user data (see GUIDATA)
55.% varargin command line arguments to untitled3 (see VARARGIN)
56.
57.% Choose default command line output for untitled3
58.handles.output = hObject;
59.
60.% Update handles structure
61.guidata(hObject, handles);
62.
63.% UIWAIT makes untitled3 wait for user response (see UIRESUME)
64.% uiwait(handles.figure1);
65.
66.
67.% --- Outputs from this function are returned to the command line.
68.function varargout = untitled3_OutputFcn(hObject, eventdata, handles)
69.% varargout cell array for returning output args (see VARARGOUT);
70.% hObject handle to figure
71.% eventdata reserved - to be defined in a future version of MATLAB
72.% handles structure with handles and user data (see GUIDATA)
73.
74.% Get default command line output from handles structure
75.varargout{1} = handles.output;
76.
77.
78.% --- Executes on button press in openfile.
79.function openfile_Callback(hObject, eventdata, handles)%打开文件
80.global filep
81.filep=OnFileOpen();
82.% hObject handle to openfile (see GCBO)
83.% eventdata reserved - to be defined in a future version of MATLAB
84.% handles structure with handles and user data (see GUIDATA)
85.
86.
87.
88.
89.% --- Executes on button press in pushbutton2.
90.function pushbutton2_Callback(hObject, eventdata, handles)%求取sift特征
91.global filep
92.global im1
93.global des1
94.global loc1
95.[im1,des1,loc1] = sift(filep);
96.showkeys(im1,loc1);
97.% hObject handle to pushbutton2 (see GCBO)
98.% eventdata reserved - to be defined in a future version of MATLAB
99.% handles structure with handles and user data (see GUIDATA)
100.
101.
102.% --- Executes on button press in pushbutton3.
103.function pushbutton3_Callback(hObject, eventdata, handles)%写入txt文件
104.global im1
105.global des1
106.global loc1
107.fid=fopen('matrix.txt','w');
108.fprintf(fid,'%f',des1);%sift特征
109.fclose(fid);
110.
111.% hObject handle to pushbutton3 (see GCBO)
112.% eventdata reserved - to be defined in a future version of MATLAB
113.% handles structure with handles and user data (see GUIDATA)
图片贴上:
design view:
result view:
property inspector:。

相关文档
最新文档