2012-12-05 105 views
1

我在m文件中有這個功能,我想爲按鈕做一個回調,但我不知道如何。誰能幫我? 這是函數:matlab GUI回調

function f=fftreal(f,N,dim); 
error(nargchk(1,3,nargin)); 

if nargin<3 
    dim=[]; 
end; 

if nargin<2 
    N=[]; 
end; 

if ~isreal(f) 
    error('Input signal must be real.'); 
end; 


[f,N,Ls,W,dim,permutedsize,order]=assert_sigreshape_pre(f,N,dim,'FFTREAL'); 

N2=floor(N/2)+1; 

f=comp_fftreal(f); 

permutedsize(1)=N2; 

f=assert_sigreshape_post(f,dim,permutedsize,order); 
end 

這是用戶接口代碼,該GUI自動生成:

function varargout = Fourier_Transform_GUI(varargin) 
%FOURIER_TRANSFORM_GUI M-file for Fourier_Transform_GUI.fig 
%  FOURIER_TRANSFORM_GUI, by itself, creates a new FOURIER_TRANSFORM_GUI or raises the existing 
%  singleton*. 
% 
%  H = FOURIER_TRANSFORM_GUI returns the handle to a new FOURIER_TRANSFORM_GUI or the handle to 
%  the existing singleton*. 
% 
%  FOURIER_TRANSFORM_GUI('Property','Value',...) creates a new FOURIER_TRANSFORM_GUI using the 
%  given property value pairs. Unrecognized properties are passed via 
%  varargin to Fourier_Transform_GUI_OpeningFcn. This calling syntax produces a 
%  warning when there is an existing singleton*. 
% 
%  FOURIER_TRANSFORM_GUI('CALLBACK') and FOURIER_TRANSFORM_GUI('CALLBACK',hObject,...) call the 
%  local function named CALLBACK in FOURIER_TRANSFORM_GUI.M with the given input 
%  arguments. 
% 
%  *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 Fourier_Transform_GUI 

% Last Modified by GUIDE v2.5 05-Dec-2012 15:46:34 

% Begin initialization code - DO NOT EDIT 
gui_Singleton = 1; 
gui_State = struct('gui_Name',  mfilename, ... 
        'gui_Singleton', gui_Singleton, ... 
        'gui_OpeningFcn', @Fourier_Transform_GUI_OpeningFcn, ... 
        'gui_OutputFcn', @Fourier_Transform_GUI_OutputFcn, ... 
        'gui_LayoutFcn', [], ... 
        'gui_Callback', []); 
if nargin && ischar(varargin{1}) 
    gui_State.gui_Callback = str2func(varargin{1}); 
end 

if 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 Fourier_Transform_GUI is made visible. 
function Fourier_Transform_GUI_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 unrecognized PropertyName/PropertyValue pairs from the 
%   command line (see VARARGIN) 

% Choose default command line output for Fourier_Transform_GUI 
handles.output = hObject; 

% Update handles structure 
guidata(hObject, handles); 

% UIWAIT makes Fourier_Transform_GUI wait for user response (see UIRESUME) 
% uiwait(handles.figure1); 


% --- Outputs from this function are returned to the command line. 
function varargout = Fourier_Transform_GUI_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 structure 
varargout{1} = handles.output; 


% --- Executes on button press in exit. 
function exit_Callback(hObject, eventdata, handles) 
% hObject handle to exit (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 FFT. 
function FFT_Callback(hObject, eventdata, handles) 
% hObject handle to FFT (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 iFFT. 
function iFFT_Callback(hObject, eventdata, handles) 
% hObject handle to iFFT (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 DFT. 
function DFT_Callback(hObject, eventdata, handles) 
% hObject handle to DFT (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 iDFT. 
function iDFT_Callback(hObject, eventdata, handles) 
% hObject handle to iDFT (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 load_file. 
function load_file_Callback(hObject, eventdata, handles) 
% hObject handle to load_file (see GCBO) 
% eventdata reserved - to be defined in a future version of MATLAB 
% handles structure with handles and user data (see GUIDATA) 
+0

Constantinos,你有一些用戶界面代碼了嗎?如果是這樣,請分享。 – Nick

+0

我把代碼放在問題中,如果它不可理解,請讓我知道 –

回答

0

正如在生成的代碼看到:

% --- Executes on button press in FFT. 
function FFT_Callback(hObject, eventdata, handles) 
% hObject handle to FFT (see GCBO) 
% eventdata reserved - to be defined in a future version of MATLAB 
% handles 

    structure with handles and user data (see GUIDATA) 

%pre-processing 
f=fftreal(f,N,dim); 
% post-processing 

這是部分代碼將在FFT按鈕按下後執行...

所以做一個調用t o你自己的功能在這裏,你應該完成。