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);
分享到:
相关推荐
此文件设计matlab-gui的一些东西。
(精品)我的简易计算器MATLAB-gui程序.doc
【工控老马出品,必属精品,亲测校正,质量保证】 资源名:MATLAB-GUI开发案例源码.zip 资源类型:程序源代码 源码说明: MATLAB-GUI开发案例源码 适合人群:新手及有一定经验的开发人员
初步学习设计MATLAB-GUI用户界面设计及实现,了解GUI用户界面上菜单的基本功能,理解设计GUI用户界面常用的程序代码。
基于MATLAB-GUI的数字图像处理课程设计代码,可实现多种图像处理操作
数值分析程序matlab-GUI,界面相对简单,初学者可以看看了解。
STK-matlab GUI仿真程序
基于Matlab-GUI的数值积分界面设计.pdf
关于-matlab-gui设计界面按键激活及源程序(精品文档).ppt
1. 通过鼠标选点绘制 B 样条:设定 B 样条曲线的度数(默认值为 2,即 3 次 B 2. 任意拖动控制点,动态绘制控制多边形和 B 样条曲线,如 Figu
哈工大数学实验的作业 实现Matlab GUI的程序 是一个画图程序
matlabGUI MATLAB GUI(源程序)学习GUI的好资料。MATLAB GUI简单的文本框数据传递(源程序)
基于MATLAB-GUI的刚性桩复合地基沉降计算.pdf
2.内容:【提供程序操作视频】m基于MATLAB-GUI的GPS数据经纬度高度解析与kalman分析软件设计 3.用处:用于GPS数据经纬度高度解析与kalman分析算法编程学习 4.指向人群:本硕博等学习教研使用,企事业简单项目方案...
matlab GUI学习资料之MATLAB GUI3:滚动条数值显示在文本框中(源程序)
用户界面(或接口)是指:人...MATLAB 为表现其基本功能而设计的演示程序demo 是使用图形界面的最好范例。 MATLAB的用户,在指令窗中运行demo 打开那图形界面后,只要用鼠标进行选择和点击,就可浏览那丰富多彩的内容。
基于MATLAB-GUI的信号采集与分析系统设计.pdf
基于MATLAB-GUI的风电机组功率特性测试数据分析.pdf
matlab开发-一个简单的Matlabgui程序。一个简单的Matlab图形用户界面程序
matlab GUI人机界面交互小程序。用GUI实现对2D图形的线形、颜色的控制。2图形可自己随意设计,程序中有详细步骤。