




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、图形用户界面编程图形用户界面编程第一页,共35页。第1页/共35页第二页,共35页。第2页/共35页第三页,共35页。第3页/共35页第四页,共35页。第4页/共35页第五页,共35页。?gwin=figure(visible,off);?set(gwin,color,1,0,0,position,100,200,300,300,.name,My program,numbertitle,off,menubar,none);?set(gwin,visible,on)第5页/共35页第六页,共35页。第6页/共35页第七页,共35页。?gwin=figuregwin = 1?set(gwin,wi
2、ndowbuttondownfcn,helpdlg(mouse button down!)?set(gwin,keypressfcn,helpdlg(keyboard pressed!) 一旦该对象指定的事件发生,将自动(zdng)调用某指定的函数,它可以是matlab文件,也可以是一组matlab程序。第7页/共35页第八页,共35页。第8页/共35页第九页,共35页。?f,p=uigetfile(*.m;*.txt,请选择(xunz)一个文件)f =fileprint.mp =E:MATLABR11work第9页/共35页第十页,共35页。第10页/共35页第十一页,共35页。?s=uis
3、etfonts = FontName: 楷体(kit)_GB2312 FontUnits: points FontSize: 42 FontWeight: bold FontAngle: normal第11页/共35页第十二页,共35页。1111.,Warning) ?h=errordlg(error:,code 1111.,Error)第12页/共35页第十三页,共35页。第13页/共35页第十四页,共35页。第14页/共35页第十五页,共35页。第15页/共35页第十六页,共35页。第16页/共35页第十七页,共35页。第17页/共35页第十八页,共35页。第18页/共35页第十九页,共3
4、5页。h_main=figure(name,a demo of gui design,menubar,none, numbertitle,off,position,100 100 300 100);h_edit=uicontrol(style,edit,backgroundcolor,1 1 1,position,20 20 50 20,. tag,myedit,string,1,horizontalalignment,left);h_but1=uicontrol(style,pushbutton,position,20 50 50 20,string,INC,. callback,v=eva
5、l(get(h_edit,string);,. set(h_edit,string,int2str(v+1););h_but2=uicontrol(style,pushbutton,position,80 50 50 20,string,DEC,. callback,v=eval(get(h_edit,string);,set(h_edit,string,int2str(v-1););第19页/共35页第二十页,共35页。function gui_counter1()%gui_counter is a demo of gui design.h_main=figure(name,a demo o
6、f gui design,menubar,none,. numbertitle,off,position,100 100 300 100);h_edit=uicontrol(style,edit,backgroundcolor,1 1 1,position,20 20 50 20,. tag,myedit,string,1,horizontalalignment,left);h_but1=uicontrol(style,pushbutton,position,20 50 50 20,string,INC,. callback,h=findobj(gcf,tag,myedit);,v=eval(
7、get(h,string);,. set(h,string,int2str(v+1););h_but2=uicontrol(style,pushbutton,position,80 50 50 20,string,DEC,. callback,h=findobj(gcf,tag,myedit);,v=eval(get(h,string);,. set(h,string,int2str(v-1););第20页/共35页第二十一页,共35页。function gui_demo()%GUI_demo is another demo of GUI design.h_main=figure(units,
8、normalized,position,0.3 0.3 0.5 0.4,. name,GUI demostration,numbertitle,off);h_axis=axes(units,normalized,position,0.3 0.15 0.6 0.7,. tag,axplot,xlim,0 10,ylim,-1 1);t=0:0.1:10;y=sin(t);line(t,y);bmp1=imread(1.bmp);bmp2=imread(2.bmp);bmp3=imread(3.bmp);bmp4=imread(4.bmp);h_1=uicontrol(style,pushbutt
9、on,units,normalized,. position,0.1 0.6 0.06 0.1,cdata,bmp1,. callback,zoom on,tooltipstring,Enable zooming);h_2=uicontrol(style,pushbutton,units,normalized,. position,0.04 0.45 0.06 0.1,cdata,bmp2,. callback,zoom xon,tooltipstring,Enable zoom on x-axis only);h_3=uicontrol(style,pushbutton,units,norm
10、alized,. position,0.16 0.45 0.06 0.1,cdata,bmp3,. callback,zoom yon,tooltipstring,Enable zoom on y-axis only);h_4=uicontrol(style,pushbutton,units,normalized,. position,0.1 0.3 0.06 0.1,cdata,bmp4,. callback,zoom off,tooltipstring,Disable zooming);第21页/共35页第二十二页,共35页。第22页/共35页第二十三页,共35页。第23页/共35页第二十
11、四页,共35页。第24页/共35页第二十五页,共35页。ctxmenu=uicontextmenu;set(gcf,uicontextmenu,ctxmenu);uimenu(ctxmenu,label,zoom on,callback,zoom on);uimenu(ctxmenu,label,x-axis zoom on,callback,zoom xon);uimenu(ctxmenu,label,y-axis zoom on,callback,zoom yon);uimenu(ctxmenu,label,zoom off,callback,zoom off);uimenu(ctxmen
12、u,label,checked,checked,on,separator,on);uimenu(ctxmenu,label,disabled,enable,off);第25页/共35页第二十六页,共35页。第26页/共35页第二十七页,共35页。第27页/共35页第二十八页,共35页。第28页/共35页第二十九页,共35页。第29页/共35页第三十页,共35页。第30页/共35页第三十一页,共35页。出射角上挡板(dn bn)下挡板(dn bn)第31页/共35页第三十二页,共35页。h1 = line(0,1,-0.09*1 1);set(h1,linewidth,5);h2 = line(
13、0,1,1.09*1 1);set(h2,linewidth,7);uu=0 1 0, 0.05 0.5;set(h_main,userdata,uu);Tag=lstcolorTag=rdradio1Tag=rdradio2Tag=rdradio3第32页/共35页第三十三页,共35页。function exec_bouncing(x)k=1;uu=get(gcf,userdata);if nargin=0, x,y,k=ginput(1);uu3=x;set(gcf,userdata,uu);endif k=1 if x1, x=1;end xx=0;yy=1;x0=0;x1=x;y1=1
14、; while(x1=1+x) xx=xx x1;y1=y1;yy=yy y1;x0=x1;x1=x1+x; end dx=1/50;xx_l=0:dx:1,xx;xx_l=sort(xx_l); yy_l=interp1(xx,yy,xx_l); h_mark=line(0,1); set(h_mark,Marker,o,markersize,8,colorg,. tag,h_ball,linewidth,5);set(h_mark,color,uu1); for i=1:length(xx_l) x0=xx_l(i); y0=yy_l(i); set(h_mark,xdata,x0,ydata, y0);pause(uu2); endend第33页/共35页第三十四页,共35页。function set_speed(key)uu=get(gcf,userdata);switch keycase 1 uu2=uu2*0.5;case 2 uu2=uu2*2;case 3 uu2=0.05;case 4 kk=get(findobj(gcf,tag,lstcolor),value); switch kk case 1 uu1=1 0 0; case 2 uu1=0 1 0; case 3 uu1=0 0 1; endend
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 演出经纪人资格证必考知识与试题及答案
- 营养师法律知识考试试题及答案
- 2025年房地产经纪人职业道德试题及答案
- 营养师与保安证考试的对比试题及答案
- 专业经纪服务必考试题及答案
- 演出经纪人资格证复习建议试题及答案
- 2025年房地产经纪资格体系完善的试题及答案
- 备战2024营养师证考试试题及答案
- 房地产经纪人考试知识深化技巧试题及答案
- 西藏高考常考题目及答案
- (一模)哈三中2025届高三第一次模拟考试 语文试题(含答案)
- 人身损害与疾病因果关系判定指南
- 招收士官学历专业审定表
- DB44∕T 1517-2015 物业服务 办公楼服务规范
- 人教鄂教版科学六年级下册全册教案
- 社区卫生服务站管理制度管理办法
- 新苏教版五年级科学下册2.5《生物的启示》教学课件
- 2006年上海市中考数学试题及答案(共10页)
- SF6气体检漏仪说明书
- 最新高人总结长期股权投资-通俗易懂式讲解资料
- 兵团科技管理信息系统PPT课件
评论
0/150
提交评论