他时说的callback函数的写法,这个其实我也不会,大体要先有一个load的Button,把你输入的文件接收过来,然后再显办法显示出来,我一直学不会gui,这方面教材也少,书中一般到这一部分都是最后一章,寥寥几页就完了。这是matlab提示的程序框架。
%我把figue名改为my001了
function varargout = my001(varargin)
% MY001 M-file for my001.fig
% MY001, by itself, creates a new MY001 or raises the existing
% singleton*.
%
% H = MY001 returns the handle to a new MY001 or the handle to
% the existing singleton*.
%
% MY001('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MY001.M with the given input arguments.
%
% MY001('Property','Value',...) creates a new MY001 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before my001_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to my001_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 my001
% Last Modified by GUIDE v2.5 07-Dec-2006 19:05:04
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @my001_OpeningFcn, ...
'gui_OutputFcn', @my001_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin & isstr(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 my001 is made visible.
function my001_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 my001 (see VARARGIN)
% Choose default command line output for my001
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes my001 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = my001_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 during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background, change
% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
set(hObject,'BackgroundColor',[.9 .9 .9]);
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
function Edit_Text_Callback(hObject, eventdata, handles)
% hObject handle to Edit_Text (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of Edit_Text as text
% str2double(get(hObject,'String')) returns contents of Edit_Text as a double
我想设计一个界面,能显示一个波形,有一个edit_text可以改变一下参数,比如频率f等。一直不会。grid on,grid off,close这几个不用编,其他的都不会了。前面板上设置了load,grid on,grid off,close,start这几个Button,一个slider还有一个Edit_text,matlab让我自己编slider还有Edit_text的callback,还有一个Axes的图形输出我不知道怎莫编的,主要是对finobj,guidata,gcbo等这些函数弄不太明白,其实我一直都没弄清handle到底是使什莫,感觉是一个面向对象的类名,因为它引出的都是property,二比她高一级的事figure,我的认识figure和property可以直接建立联系,一直没弄明白handle到底是什莫,还希望路过的大牛指点! |