我在m文件中有这个功能,我想对按钮进行回调,但我不知道如何。谁能帮我? 这是功能:
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 :(得分: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按钮后执行的代码的一部分......
所以在这里打电话给你自己的功能,你应该完成。