资源描述:
《matlab实验6图形用户界面设计》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、实验6学号:201100000姓名:000实验6.图形用户界面设计一、实验目的1.掌握图形对象属性的基本操作;2.掌握菜单及对话框设计、建立控件对象的方法。二、实验环境1.计算机2.matlab7.x三、实验说明1.正确操作,认真观察;2.实验学时:2学时;3.学会使用help;4.保存整理实验结果,提交实验报告。四、实验内容1.设计如教材P374图1所示的菜单,并在此基础上增加选项:可以改变曲线的颜色,可以改变窗口背景颜色。2.(选做)采用图形用户界面,从键盘输入参数a、b、n的值,考察参数对极坐标曲线的影响。4实验6学号:20110
2、0000姓名:000五、实验程序及结果1.figure('Color',[111],'Position',[400300500250],'Name','201100000','NumberTitle','off','MenuBar','none');hplot=uimenu(gcf,'Label','&plot');%设置Plot菜单项uimenu(hplot,'Label','SinWave','Call',['t=-pi:pi/20:pi;','y=sin(t);','plot(t,y);','set(hgon,''Enable''
3、,''on'');','set(hgoff,''Enable'',''on'');','set(hlinecolor,''Enable'',''on'');'],'Accelerator','s');uimenu(hplot,'Label','CosWave','Call',['t=-pi:pi/20:pi;','y=cos(t);','plot(t,y);','set(hgon,''Enable'',''on'');','set(hgoff,''Enable'',''on'');','set(hlinecolor,''Enable''
4、,''on'');'],'Accelerator','c');%设置Option菜单项hoption=uimenu(gcf,'Label','&option');hgon=uimenu(hoption,'Label','&gridon','Call','gridon','Enable','off');hgoff=uimenu(hoption,'Label','&gridoff','Call','gridoff','Enable','off');hlinecolor=uimenu(hoption,'Label','&LineColor',
5、'Separator','on','Enable','off');4实验6学号:201100000姓名:000uimenu(hlinecolor,'Label','&red','Accelerator','r','Call','set(plot(t,y),''Color'',''r'');');uimenu(hlinecolor,'Label','&blue','Accelerator','b','Call','set(plot(t,y),''Color'',''b'');');uimenu(hlinecolor,'Label','&g
6、reen','Accelerator','g','Call','set(plot(t,y),''Color'',''g'');');%设置Exit菜单项uimenu(gcf,'Label','Exit','Call','close(gcf)');%设置快捷菜单hc=uicontextmenu;hlc=uimenu(hc,'Label','背景颜色');uimenu(hlc,'Label','red','Call','set(gcf,''Color'',''r'');');uimenu(hlc,'Label','blue','Call',
7、'set(gcf,''Color'',''b'');');uimenu(hlc,'Label','green','Call','set(gcf,''Color'',''g'');');set(gcf,'UIContextMenu',hc);4实验6学号:201100000姓名:0002.%设置对话框的颜色(灰色),位置,大小等属性值hf=figure('Color',[0.50.50.5],'Position',[200200400250],'Name','201100000','NumberTitle','off','MenuBar'
8、,'none');%设置图形演示界面的位置,大小,不设的话默认在中心位置axes('Position',[0.350.230.60.7]);%设置提示部分uicontrol(hf,'Style','Text