matlab窗口界面编辑
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
编辑一个窗口实现以下功能:输入几个人的成绩求其平均值,最大值,最小值
clear
clc
hf=figure('Color',[0,1,1],'Position',[100,200,400,200],... 'Name','成绩分析
','NumberTitle','off','MenuBar','none');
uicontrol(hf,'Style','Text', 'Units','normalized',...
'Position',[0.03,0.8,0.35,0.1],'Horizontal','center',...
'String','输入成绩','fontsize',[14] ,'Back',[0 1 1]); uicontrol(hf,'Style',' Text
','Position',[0.4,0.8,0.25,0.1],...
'Units','normalized','Horizontal','center',...
'String','最高分', 'fontsize',[14],'Back',[0 1 1]); he1=uicontrol(hf,'Style',' Text
','Position',[0.7,0.8,0.25,0.1],...
'Units','normalized','Back',[1,1,0]);
uicontrol(hf,'Style','Text','Position',[0.4,0.6,0.25,0.1],. ..
'Units','normalized','Horizontal','center',...
'String','最低分', 'fontsize',[14] ,'Back',[0 1 1]);
he2=uicontrol(hf,'Style',' Text
','Position',[0.7,0.6,0.25,0.1],...
'Units','normalized','Back',[1,1,0]);
uicontrol(hf,'Style','Text','Position',[0.4,0.4,0.25,0.1],. ..
'Units','normalized','Horizontal','center',...
'String','平均分', 'fontsize',[14] ,'Back',[0 1 1]); he3=uicontrol(hf,'Style',' Text
','Position',[0.7,0.4,0.25,0.1],...
'Units','normalized','Back',[1,1,0]);
he=uicontrol(hf,'Style','Edit','Position',[0.05,0.6,0.35,0. 15],...
'Units','normalized','Back',[1,1,0]);
i=1;
COMM=[ 'A(i)=str2num(get(he,''String'')); ',...
' i=i+1;'...
' set(he,''string'', [])']
uicontrol(hf,'Style','push','Position',[0.05,0.4,0.15,0.1], ...
'Units','normalized','Horizontal','center',...
'String','录入', 'fontsize',[14],'call',COMM)
COMM1=['a=max(A);b=min(A);c=mean(A);'...
'set(he1,''string'',a); set(he2,''string'',b); ' ...
'set(he3,''string'',c) ;']
uicontrol(hf,'Style','push','Position',[0.25,0.4,0.15,0.1], ...
'Units','normalized','Horizontal','center',...
'String','显示', 'fontsize',[14],'call',COMM1)
COMM2=['A=[];i=1;set(he1,''string'',
[]);set(he2,''string'', []);set(he3,''string'', [])']
uicontrol(hf,'Style','push','Position',[0.05,0.1,0.4,0.2],. ..
'Units','normalized','Horizontal','center',...
'String','清空', 'fontsize',[14],'call',COMM2)
uicontrol(hf,'Style','Push','Position',[0.55,0.1,0.4,0.2],. ..
'String','退出
','Units','normalized','fontsize',[18],'Call','close(hf)');
1、点击运行:
2输入数据:56 录入 67 录入 78 录入 89 录入 90 录入
输完数据后点击显示:
3如果要重新输入数据,那么只要点击清空就可以进行下一次计算
如计算结束,只要点击退出就可以退出界面。