利用Matlab的图形用户界面(GUI)功能,设计并实现实验主界面
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
(1)利用Matlab的图形用户界面(GUI)功能,设计并实现实验主界面;
(2) 实现在“符号计算”图形用户界面中的各项符号计算功能,如实现Matlab的求极限、求导、求不定积分与定积分、级数求和、方程组的符号求解、常微分方程的符号求解等符号计算;
(3) 利用Matlab的二维、三维绘图功能,实现图形用户界面(GUI)中的部分符号计算的可视化,即给出符号计算实例的同时实现该实例的图形化描述。
如下图给出了一个简单的GUI界面,学生可以参考如下图设计出自己的GUI界面。
程序如下:
hf=figure('Position',[200,200,700,500],...
'Name','信计08(2)班阿卜杜热黑木20080803417', ...
'NumberTitle','off','MenuBar','none');
uicontrol(hf,'Style','Frame','Position',[0,0.15,0.45,1],...
'Units','normalized','Back',[0,1,1]);
COMM1=['n=str2num(get(he1,''String''));', ...%求导连接
'b=sym(get(he7,''String''));',...
'dec=diff(b,n);', ...
'set(he8,''string'',char(dec));'];
COMM2=['a=str2num(get(he2,''String''));', ...%求极限连接
'f=sym(get(he7,''String''));',...
'lim=limit(f,a);', ...
'set(he8,''string'',char(lim));'];
COMM3=['g=sym(get(he7,''String''));',... %不定积分连接
'int_1=int(g);', ...
'set(he8,''string'',char(int_1));'];
COMM4=['a=str2num(get(he3,''String''));', ... %级数求和连接
'b=str2num(get(he5,''String''));', ...
'f=sym(get(he7,''String''));',...
'sum_1=symsum(f,a,b);', ...
'set(he8,''string'',char(sum_1));'];
COMM5=['a=str2num(get(he4,''String''));', ... %定积分连接
'b=str2num(get(he6,''String''));', ...
'f=sym(get(he7,''String''));',...
'int_2=int(f,a,b);', ...
'set(he8,''string'',char(int_2));'];
COMM6=['f=get(he7,''String'');',...
'dsolve_1=dsolve(f,''x'');', ...
'set(he8,''string'',char(dsolve_1));'];
COMM7=['f=get(he7,''String'');',...
'ezplot(f);'];
COMM8=['g=get(he8,''String'');',...
'ezplot(g);'];
uicontrol(hf,'Style','Push','Position',[0.02,0.9,0.11,0.06],...
'String','求导','Units','normalized','Call',COMM1); uicontrol(hf,'Style','Text','Position',[0.17,0.85,0.08,0.1],...
'Units','normalized','Horizontal','center',...
'String','阶数','Back',[0,1,1]);
he1=uicontrol(hf,'Style','Edit','Position',[0.25,0.9,0.15,0.06],...
'Units','normalized','Back',[0,1,0]);
uicontrol(hf,'Style','Push','Position',[0.02,0.72,0.13,0.06],...
'String','求极限','Units','normalized','Call',COMM2);
uicontrol(hf,'Style','Text','Position',[0.17,0.67,0.08,0.1],...
'Units','normalized','Horizontal','center',...
'String','极限点','Back',[0,1,1]);
he2=uicontrol(hf,'Style','Edit','Position',[0.25,0.72,0.15,0.06],...
'Units','normalized','Back',[0,1,0]);
uicontrol(hf,'Style','Push','Position',[0.02,0.58,0.13,0.06],...
'String','不定积分','Units','normalized','Call',COMM3);
uicontrol(hf,'Style','Push','Position',[0.02,0.45,0.13,0.06],...
'String','级数求和','Units','normalized','Call',COMM4);
uicontrol(hf,'Style','Text','Position',[0.31,0.44,0.06,0.06],...
'Units','normalized','Horizontal','center',...
'String','上限','Back',[0,1,1]);
he5=uicontrol(hf,'Style','Edit','Position',[0.38,0.45,0.06,0.06],...
'Units','normalized','Back',[0,1,0]);
uicontrol(hf,'Style','Text','Position',[0.17,0.44,0.06,0.06],...
'Units','normalized','Horizontal','center',...
'String','下限','Back',[0,1,1]);
he3=uicontrol(hf,'Style','Edit','Position',[0.24,0.45,0.06,0.06],...
'Units','normalized','Back',[0,1,0]);
uicontrol(hf,'Style','Push','Position',[0.02,0.32,0.13,0.06],...
'String','求定积分','Units','normalized','Call',COMM5);
uicontrol(hf,'Style','Text','Position',[0.31,0.31,0.06,0.06],...
'Units','normalized','Horizontal','center',...
'String','上限','Back',[0,1,1]);
he6=uicontrol(hf,'Style','Edit','Position',[0.38,0.32,0.06,0.06],...
'Units','normalized','Back',[0,1,0]);
uicontrol(hf,'Style','Text','Position',[0.17,0.3,0.08,0.06],...
'Units','normalized','Horizontal','center',...
'String','下限','Back',[0,1,1]);
he4=uicontrol(hf,'Style','Edit','Position',[0.24,0.32,0.06,0.06],...
'Units','normalized','Back',[0,1,0]);
uicontrol(hf,'Style','Push','Position',[0.02,0.2,0.16,0.06],...
'String','解微分方程','Units','normalized','Call',COMM6);
uicontrol(hf,'Style','text','Position',[0.48,0.9,0.13,0.06],...
'String','原函数','Units','normalized');
he7=uicontrol(hf,'Style','edit','Position',[0.65,0.9,0.30,0.06],...
'String','','Units','normalized','Back',[0,1,0]);
uicontrol(hf,'Style','text','Position',[0.48,0.77,0.13,0.06],...
'String','结果函数','Units','normalized');
he8=uicontrol(hf,'Style','text','Position',[0.65,0.77,0.30,0.06],...
'String','','Units','normalized','Back',[0,1,0]);
h_axes=axes('position',[0.55,0.2,0.4,0.5]);
uicontrol(hf,'Style','push','Position',[0.58,0.02,0.13,0.06],...
'String','初始绘图','Units','normalized','call',COMM7);
uicontrol(hf,'Style','push','Position',[0.80,0.02,0.13,0.06],...
'String','结果绘图','Units','normalized','call',COMM8);
uicontrol(hf,'Style','Push','Position',[0.02,0.02,0.08,0.06],...
'String','退出','Units','normalized','Call', 'close');。