资源描述:
《实验6图形用户界面设计.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、实验6.图形用户界面设计一、实验目的1.掌握图形对象属性的基本操作;2.掌握菜单及对话框设计、建立控件对象的方法。二、实验环境1.计算机;2.Matlab软件。三、实验说明1.正确操作,认真观察;2.实验学时:2学时;3.学会使用help;4.保存整理实验结果,提交实验报告。四、实验内容1.设计如教材P374图1所示的菜单,并在此基础上增加选项:可以改变曲线的颜色、线型;可以改变窗口背景颜色。2.(选做)采用图形用户界面,从键盘输入参数a、b、n的值,考察参数对极坐标曲线的影响。五、实验程序及结果程序如下:screen=get(0,'ScreenSize');W=
2、screen(3);H=screen(4);figure('Color',[1,1,1],'Position',[0.2*H,0.2*H,0.5*W,0.3*W],...'Name','图形演示系统','NumberTitle','off','MenuBar','none');%定义Plot菜单项hplot=uimenu(gcf,'Label','&Plot');uimenu(hplot,'Label','SineWave','Call',...['t=-pi:pi/20:pi;','y=plot(t,sin(t));']);uimenu(hplot,'Label
3、','CosineWave','Call',...['t=-pi:pi/20:pi;','y=plot(t,cos(t));']);hcor=uimenu(hplot,'Label','&Color','Separator','on');uimenu(hcor,'Label','&Red','Call','set(y,''Color'',''r'');');uimenu(hcor,'Label','&Blue','Call','set(y,''Color'',''b'');');uimenu(hcor,'Label','&Yellow','Call','set(y
4、,''Color'',''y'');');uimenu(hcor,'Label','&Green','Call','set(y,''Color'',''g'');');hwincor=uimenu(gcf,'Label','&WindowColor','Separator','on');uimenu(hwincor,'Label','&Red','Accelerator','r',...'Call','set(gcf,''Color'',''r'');');uimenu(hwincor,'Label','&Blue','Accelerator','b',...'C
5、all','set(gcf,''Color'',''b'');');uimenu(hwincor,'Label','&Yellow',...'Call','set(gcf,''Color'',''y'');');uimenu(hwincor,'Label','&White',...'Call','set(gcf,''Color'',''w'');');hls=uimenu(gcf,'Label','LineStyle');uimenu(hls,'Label','虚线','Call','set(y,''LineStyle'','':'');');uimenu(hls
6、,'Label','实线','Call','set(y,''LineStyle'',''-'');');uimenu(gcf,'Label','&Quit','Call','close(gcf)');图形结果: