`
deepfuture
  • 浏览: 4333641 次
  • 性别: Icon_minigender_1
  • 来自: 湛江
博客专栏
073ec2a9-85b7-3ebf-a3bb-c6361e6c6f64
SQLite源码剖析
浏览量:79430
1591c4b8-62f1-3d3e-9551-25c77465da96
WIN32汇编语言学习应用...
浏览量:68389
F5390db6-59dd-338f-ba18-4e93943ff06a
神奇的perl
浏览量:101511
Dac44363-8a80-3836-99aa-f7b7780fa6e2
lucene等搜索引擎解析...
浏览量:281224
Ec49a563-4109-3c69-9c83-8f6d068ba113
深入lucene3.5源码...
浏览量:14608
9b99bfc2-19c2-3346-9100-7f8879c731ce
VB.NET并行与分布式编...
浏览量:65582
B1db2af3-06b3-35bb-ac08-59ff2d1324b4
silverlight 5...
浏览量:31322
4a56b548-ab3d-35af-a984-e0781d142c23
算法下午茶系列
浏览量:45211
社区版块
存档分类
最新评论

matlab-GUI程序(2)

 
阅读更多

1、GUI刚打开时要执行的,此时GUI的所有对象都已经建立

% --- Executes just before test1 is made visible.
function test1_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 test1 (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

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

 

 
2、输出参数返回到命令行
% --- Outputs from this function are returned to the command line.

% --- Outputs from this function are returned to the command line.function varargout = test1_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;

 3、更新参数和输入参数

guidata(hObject, handles);

4、选择默认命令行

handles.output = hObject;

5、响应函数

% --- Executes on button press in btn_draw.
function btn_draw_Callback(hObject, eventdata, handles)
% hObject    handle to btn_draw (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)



function a_num_Callback(hObject, eventdata, handles)
% hObject    handle to a_num (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 a_num as text
%        str2double(get(hObject,'String')) returns contents of a_num as a double


% --- Executes during object creation, after setting all properties.
function a_num_CreateFcn(hObject, eventdata, handles)
% hObject    handle to a_num (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function b_num_Callback(hObject, eventdata, handles)
% hObject    handle to b_num (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 b_num as text
%        str2double(get(hObject,'String')) returns contents of b_num as a double


% --- Executes during object creation, after setting all properties.
function b_num_CreateFcn(hObject, eventdata, handles)
% hObject    handle to b_num (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function c_num_Callback(hObject, eventdata, handles)
% hObject    handle to c_num (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 c_num as text
%        str2double(get(hObject,'String')) returns contents of c_num as a double


% --- Executes during object creation, after setting all properties.
function c_num_CreateFcn(hObject, eventdata, handles)
% hObject    handle to c_num (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

 6、为3个文本框编写代码

 

function a_num_Callback(hObject, eventdata, handles)
% hObject    handle to a_num (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 a_num as text
%        str2double(get(hObject,'String')) returns contents of a_num as a double
numa=str2double(get(hObject,'string'));
if isnan(numa)
      errordlg('请输入数字','输入错误','modal');
end
handles.numa=numa;
guidata(hObject, handles);

      

% --- Executes during object creation, after setting all properties.
function a_num_CreateFcn(hObject, eventdata, handles)
% hObject    handle to a_num (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function b_num_Callback(hObject, eventdata, handles)
% hObject    handle to b_num (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 b_num as text
%        str2double(get(hObject,'String')) returns contents of b_num as a double
numb=str2double(get(hObject,'string'));
if isnan(numb)
      errordlg('请输入数字','输入错误','modal');
end
handles.numb=numb;
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function b_num_CreateFcn(hObject, eventdata, handles)
% hObject    handle to b_num (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function c_num_Callback(hObject, eventdata, handles)
% hObject    handle to c_num (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 c_num as text
%        str2double(get(hObject,'String')) returns contents of c_num as a double
numc=str2double(get(hObject,'string'));
if isnan(numc)
      errordlg('请输入数字','输入错误','modal');
end
handles.numc=numc;
guidata(hObject, handles);

 

0
3
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics