龙空技术网

MATLAB的求解函数极限GUI计算界面

云龙派 289

前言:

目前大家对“matlab布局调整”大约比较珍视,你们都需要学习一些“matlab布局调整”的相关知识。那么小编在网摘上网罗了一些关于“matlab布局调整””的相关资讯,希望你们能喜欢,咱们快快来学习一下吧!

摘要:基于MATLAB的guide制作求解函数极限的GUI计算界面。

1.界面设计

MATLAB提供了可视化的用户界面开发环境(GUDevelopment Environment, GUIDE),实现“所见即所得”。

步骤1:在MATLAB命令窗口输入guide

步骤2:设计并完成GUI的图形控件布局

步骤3 主要按键的回调函数以及相应控件的程序

(1)修改界面左上角的名称的程序要在GUI的打开的回调函数中执行。

function LimitGUI_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 LimitGUI (see VARARGIN)% Choose default command line output for LimitGUIhandles.output = hObject;movegui(gcf,'center');set(gcf,'NumberTitle','off','Name','函数求极限计算GUI界面');% Update handles structureguidata(hObject, handles);% UIWAIT makes LimitGUI wait for user response (see UIRESUME)% uiwait(handles.figure1);

(2)开始计算函数极限的回调函数,同时输入函数参数,求解结果。

function pushbutton1_Callback(hObject, eventdata, handles)% hObject    handle to pushbutton1 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)x = sym( get(handles.edit2,'string'));%通过sym转成变量类型f = str2sym(get(handles.edit1,'string'));%str2sym函数  将字符类型转化为sym类型x0 = str2num(get(handles.edit4,'string'));I = double(limit(f,x,x0));set(handles.edit3,'string',I);%%利用char将sym类型转成字符类型

2.界面使用说明

基于MATLAB的GUI界面设计了一个计算函数极限的计算界面如下:

计算函数极限:点击运行LimitGUI.m——输入函数和变量和求解的函数值——点击计算即可出现结果。需要GUI的.m程序和fig文件,可以进行赞赏后截图(10元及以上),进行联系,或者在微信公众号云龙派点击“联系掌门”进行联系,或者在公众号内回复截图,几小时内会回复。界面编程不易,还请见谅!

3.界面举例计算

Step1:输入求极限的函数、变量、求极限值 。

Step2:点击计算,可获得相应的结果。

Step3:修改极限值x,点击计算,可获得相应的结果。

Step4:点击清除按键,清除界面输入。

3.GUI主要程序如下

function pushbutton1_Callback(hObject, eventdata, handles)% hObject    handle to pushbutton1 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)x = sym( get(handles.edit2,'string'));%通过sym转成变量类型f = str2sym(get(handles.edit1,'string'));%str2sym函数  将字符类型转化为sym类型x0 = str2num(get(handles.edit4,'string'));I = double(limit(f,x,x0));set(handles.edit3,'string',I);%%利用char将sym类型转成字符类型% --- Executes on button press in pushbutton2.function pushbutton2_Callback(hObject, eventdata, handles)% hObject    handle to pushbutton2 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)set(handles.edit1,'string','');set(handles.edit2,'string','');set(handles.edit3,'string','');set(handles.edit4,'string','');% --- Executes on button press in pushbutton3.function pushbutton3_Callback(hObject, eventdata, handles)% hObject    handle to pushbutton3 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)closereq;

本文内容来源于网络,仅供参考学习,如内容、图片有任何版权问题,请联系处理,24小时内删除。

作 者 | 郭志龙

编 辑 | 郭志龙

校 对 | 郭志龙

标签: #matlab布局调整 #matlab gui滑动条