GUI程序设计
b=str2num(get(handles.edit2,'string'));
yunxuan=get(handles.popupmenu1,'value');
switchyunsuan
case1
c=a+b;
case2
c=a-b;
case3
c=a*b;
case4
c=a/b;
end
set(handles.text2,'string',c)
实验四GUI设计
专业
学号
姓名
成绩
1.创建GUI绘制方程 图形,需要显示绘图结果的坐标系窗口,还能够输入a,b,c的值和x取值范围(最大值和最小值)。
设计的界面结果:
a=str2num(get(handles.edit1,'string'));
b=str2num(get(handles.edit2,'string'));
c=str2num(get(handles.edit3,'string'));
x0=str2num(get(handles.edit5,'string'));
x1=str2num(get(handles.edit6,'string'));
x=x0:0.1:x1;
y=a*x.^2+b*x+c;
axes(handles.axes1)
plot(x,y)
2.设计一个GUI,完成画出y=sin(x)、y=cos(x)和y=x3.的波形图。
设计的界面结果:
t=0:0.1(handles.axes1)
plot(t,x)
t=0:0.1:2*pi;
y=cos(t);
axes(handles.axes1)
plot(t,y)
t=0:0.1:2*pi;
z=t.^3;
axes(handles.axes1)
plot(t,z)
quit
3.创建一个GUI,含有下拉菜单,下拉菜单中有背景颜色选择。
设计的界面结果:
Set(gcf,’color’,’r’)
4.使用GUI设计一个计算器,可以实现两个数的和运算,这两个加数可以任意输入,结果显示在窗口中。
设计的界面结果:
a=str2num(get(handles.edit1,'string'));
b=str2num(get(handles.edit2,'string'));
c=a+b;
set(handles.text3,'string',c)
5.设计一个能够运算加减乘除的计算器。
a=str2num(get(handles.edit1,'string'));