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);
分享到:
相关推荐
7. **编译与打包**:学习如何将MATLAB GUI程序编译为独立的可执行文件,方便在没有MATLAB环境的机器上运行。 8. **错误处理**:理解和运用错误处理机制,可以提升GUI的稳定性和用户体验。 通过"matlab-gui-...
此文件设计matlab-gui的一些东西。
第6-MATLAB-GUI程序设计初步.pptx
Matlab-GUI 编程实例(加法器)是一篇关于 Matlab-GUI 编程的教程,旨在指导读者如何使用 Matlab-GUI 实现一个简单的加法器程序。本篇教程分步骤讲解了如何创建一个 GUI 文件、添加控件、编写代码以实现两数相加的...
Matlab可以用来设计旅游路线优化的程序,它能够结合GUI的设计思想和步骤,使用户能够通过界面直观地输入需要优化的景点,然后通过Matlab的计算功能输出优化后的路线。这样的程序不仅提高了用户体验,而且提高了效率...
在“MATLAB-GUI_matlabGUI_”的学习资源中,你将深入理解GUI设计的基本概念和实践技巧。 一、GUI设计基础 GUI设计主要涉及以下几个关键元素: 1. **控件**:如按钮、文本框、滑块、复选框等,用于接收用户的输入或...
基于MATLAB-GUI的简易计算器设计是一个利用MATLAB的图形用户界面开发环境(GUIDE)构建的项目。MATLAB是一款强大的数学软件,主要用于算法开发、数据可视化、数据分析以及数值计算。它的GUI特性允许用户创建直观的、...
【工控老马出品,必属精品,亲测校正,质量保证】 资源名:MATLAB-GUI开发案例源码.zip 资源类型:程序源代码 源码说明: MATLAB-GUI开发案例源码 适合人群:新手及有一定经验的开发人员
在GUI(图形用户界面)设计方面,MATLAB提供了丰富的工具和函数,使得非专业程序员也能构建出功能丰富的应用程序。本资料"精通MATLAB-GUI设计源代码"是针对这一主题的深入学习资源,旨在帮助用户掌握MATLAB GUI的...
MATLAB GUI程序通常包括“OpeningFcn”(初始化函数)、控件回调函数(如按钮按下事件)以及数据处理和绘图函数。 "mouse2.m"和"mouse.m"可能包含了与鼠标交互相关的函数。在MATLAB GUI中,可以编写这些函数来监听...
通过研究这个MATLAB-GUI程序,初学者可以学习到如何结合MATLAB的数值计算功能与GUI设计,创建自己的交互式应用,例如解决线性代数问题、进行拟合和优化、模拟动态系统等。同时,这也能帮助他们理解如何将复杂的算法...
Matlab-GUI,全称是MATLAB图形用户界面(Graphical User Interface),是MATLAB编程环境中的一种工具,允许用户通过图形化方式与程序交互。在偏振光实验中,MATLAB-GUI可以作为数据采集、处理和分析的强大平台,帮助...
### 第6章:MATLAB-GUI程序设计 #### 一、MATLAB GUI程序设计概述 MATLAB提供了强大的GUI开发工具——GUIDE(Graphical User Interface Development Environment),用于帮助用户创建交互式的图形用户界面。通过...
2. 事件驱动编程:MATLAB GUI程序设计中,事件驱动编程是指程序的执行是由用户的交互事件驱动的,如按钮的点击、文本框的输入等。 3. 回调函数的编写:在MATLAB GUI程序设计中,回调函数是指程序在响应用户交互事件...
Matlab GUI(图形用户界面)是Matlab编程中一个强大的工具,它允许用户通过交互式界面与程序进行交互,而非仅仅依赖命令行操作。在"Matlab-GUI-基础编程.zip"这个压缩包中,包含了一份名为"Matlab-GUI-基础编程.pdf...
# -MATLAB-GUI- 基于MATLAB的图像处理GUI软件 # 软件说明 本资源为基于MATLAB设计的数字图像处理软件源码,有自己设计的GUI、移植于MATLAB官网的标签页...simpletab.m程序,为标签页生成程序(MATLAB官网下载)。
2. 电机仿真管理系统界面的设计使用了MATLAB语言中的GUI,提供了交互式的用户界面设计工具。 3. 电机仿真管理系统可以实现电机仿真的自动化、可视化和交互化,提高了电机仿真的效率和准确性。 4. 基于MATLAB-GUI的...
GUI设计的主要目的包括方便函数的重复使用、为用户提供实用的函数或程序、以及创建交互式的分析方法示例。通过GUI,用户能够输入参数,操作软件,得到所需的动力性能评价指标的特性图。 综上所述,Matlab-GUI在汽车...
"STK-matlab GUI仿真程序"是一个基于MATLAB的图形用户界面(GUI)应用程序,...如果你计划进入这个领域,建议从理解MATLAB基础开始,然后逐步学习STK的文档和相关教程,最后实践编写和调试GUI程序,以提升技能和经验。