MATLAB程序设计基础 - 欢迎进入山东大学服务机器人研究室_9171.pptVIP

  • 7
  • 0
  • 约7.99千字
  • 约 36页
  • 2015-12-04 发布于湖北
  • 举报

MATLAB程序设计基础 - 欢迎进入山东大学服务机器人研究室_9171.ppt

菜单编辑器(Menu Editor) 编辑菜单项 * 回调函数编辑器(Callback Editor) 编辑控件属性所对应的回调函数 * 例:示意小球碰撞过程 出射角 上挡板 下挡板 * h1 = line([0,1],-0.09*[1 1]); set(h1,linewidth,5); h2 = line([0,1],1.09*[1 1]); set(h2,linewidth,7); uu={[0 1 0], 0.05 0.5}; set(h_main,userdata,uu); Tag=lstcolor Tag=rdradio1 Tag=rdradio2 Tag=rdradio3 * function exec_bouncing(x) k=1;uu=get(gcf,userdata); if nargin==0, [x,y,k]=ginput(1);uu{3}=x;set(gcf,userdata,uu); end if k==1 if x0, x=0.1;end if x1, x=1;end xx=[0];yy=[1];x0=0;x1=x;y1=1; 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,uu{1}); for i=1:length(xx_l) x0=xx_l(i); y0=yy_l(i); set(h_mark,‘xdata’,x0,‘ydata’,… y0);pause(uu{2}); end end * function set_speed(key) uu=get(gcf,userdata); switch key case 1 uu{2}=uu{2}*0.5; case 2 uu{2}=uu{2}*2; case 3 uu{2}=0.05; case 4 kk=get(findobj(gcf,tag,lstcolor),value); switch kk case 1 uu{1}=[1 0 0]; case 2 uu{1}=[0 1 0]; case 3 uu{1}=[0 0 1]; end end if key=3 hh=gco; h1=findobj(gcf,tag,rdradio1);set(h1,value,0); h2=findobj(gcf,tag,rdradio2);set(h2,value,0); h3=findobj(gcf,tag,rdradio3);set(h3,value,0); set(hh,value,1); end set(gcf,userdata,uu); exec_bouncing(uu{3}); * MATLAB程序设计基础 图形用户界面编程 * MATLAB图形界面中各对象关系 根对象 root 图形窗口对象 figure 右键菜单对象 uicontextmenu 菜单对象 uimenu 控件对象 uicontrol 坐标轴对象 axes 线对象 line 文字对象 text 表面图对象 surface 图像对象 image 光源对象 light * 窗口对象及其属性设定 窗口对象的建立 hwin=figure(属性1,属性值1,属性2,属性值2,…) hwin为图形窗口的句柄,matlab环境允许打开多个窗口,每个窗口都对应自己的句柄,通过该句柄可以进一步对窗口的属性等进行操作。 hwin=gcf 获得当前窗口的句柄。 * 图形窗口的属性 * 常用属性 color属性 由红绿蓝三原色组成,取值范围为0到1。 menubar属性 设置菜单条的形式。 name属性 设置图形窗口的标题栏中标题内容,其属性值为一字符串。 numbertitle属性 是否显示图形窗口标题栏中的图形标号。 units属性 设定图形单位。如:pixels(象素点)、inches(英寸)、c

文档评论(0)

1亿VIP精品文档

相关文档