After an afternoon, I read some information and finally completed the callback function in the Matlab GUI.
See the bottom ~
Umtitled3.m:
Function varargout = untitled3 (varargin) % untitled3 M-file for untitled3.fig % untitled3, by itself, creates a new untitled3 or raises the existing % Singleton *. % H = untitled3 returns the handle to a new untitled3 or the handle to % the existing Singleton *. % untitled3 ('callback', hobject, eventdata, handles ,...) callthe local % function named callback in untitled3.m with the given input arguments. % untitled3 ('properties', 'value ',...) creates a new untitled3 or raises the % existing Singleton *. starting from the left, property value pairs are % applied to the Gui before untitled3_openingfunction gets called. an % unrecognized property name or invalid value makes property application % stop. all inputs are passed to untitled3_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 % Copyright 2002-2003 the Mathworks, Inc. % edit the above text to modify the response to help untitled3 % last modified by guide v2.5 18-Mar-2012 16:58:53% begin initialization code-do not editgui_singleton = 1; gui_state = struct ('gui _ name', mfilename ,... 'gui _ Singleton ', gui_singleton ,... 'gui _ openingfcn ', @ untitled3_openingfcn ,... 'gui _ outputfcn ', @ untitled3_outputfcn ,... 'gui _ layoutfcn ', [],... 'gui _ callback', []); If nargin & ischar (varargin {1}) gui_state.gui_callback = str2func (varargin {1}); endif nargout [varargout {1: nargout}] = gui_mainfcn (gui_state, varargin {:}); else gui_mainfcn (gui_state, varargin {:}); end % end initialization code-do not edit % --- executes just before untitled3 is made visible. function untitled3_openingfcn (hobject, eventdata, handles, varargin) % this function has no output ARGs, see outputfcn. % hobject handle to figure % eventdata reserved-to be defined in a future version of MATLAB % handles structure with handles and user data (see guidata) % varargin command line arguments to untitled3 (see varargin) % choose Default command line output for untitled3handles. output = hobject; % update handles structureguidata (hobject, handles); % uiwait makes untitled3 wait for user response (see uiresume) % uiwait (handles. figure1); % --- outputs from this function are returned to the command line. function varargout = untitled3_outputfcn (hobject, eventdata, handles) % varargout cell array for returning output ARGs (see varargout ); % hobject handle to figure % eventdata reserved-to be defined in a future version of MATLAB % handles structure with handles and user data (see guidata) % get default command line output from handles structurevarargout {1} = handles. output; % --- executes on button press in openfile. function openfile_callback (hobject, eventdata, handles) % open the file global filepfilep = onfileopen (); % hobject handle to openfile (see gcbo) % eventdata reserved-to be defined in a future version of MATLAB % handles structure with handles and user data (see guidata) % --- executes on button press in pushbutton2.function pushbutton2_callback (hobject, eventdata, handles) % obtain the sift feature global filepglobal im1global des1global loc1 [im1, DES1, loc1] = sift (filep); showkeys (im1, loc1); % hobject handle to pushbutton2 (see gcbo) % eventdata reserved-to be defined in a future version of MATLAB % handles structure with handles and user data (see guidata) % --- executes on button press in pushbutton3.function pushbutton3_callback (hobject, eventdata, handles) % write the TXT file global im1global des1global loc1fid=fopen('matrix.txt ', 'w'); fprintf (FID,' % F', DES1); % sift feature fclose (FID ); % hobject handle to pushbutton3 (see gcbo) % eventdata reserved-to be defined in a future version of MATLAB % handles structure with handles and user data (see guidata)
Image pasting:
Design view:
Result View:
Property inspector: