第一范文网 - 专业文章范例文档资料分享平台

实验6 图形用户界面设计 

来源:用户分享 时间:2025/8/25 22:04:30 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

实验6

实验6. 图形用户界面设计

一、 实验目的

1. 掌握图形对象属性的基本操作;

2. 掌握菜单及对话框设计、建立控件对象的方法。 二、 实验环境

1. 计算机 2. matlab7.1 三、 实验说明

1. 正确操作,认真观察; 2. 实验学时:2学时; 3. 学会使用help;

4. 保存整理实验结果,提交实验报告。 四、 实验内容

1.设计如教材P374 图1所示的菜单,并在此基础上增加选项:可以改变曲线的颜色,可以改变窗口背景颜色。

2.(选做)采用图形用户界面,从键盘输入参数a、b、n的值,考察参数对极坐标曲线??acos(b?n?)的影响。五、 实验程序及结果

1. screen=get(0,'ScreenSize');

W=screen(3);H=screen(4);

figure('Color','w','Position',[0.2*H,0.2*H,0.5*W,0.3*H],...

'Name','菜单设计实验','NumberTitle','off','MenuBar','none'); hplot=uimenu(gcf,'Label','&Plot'); %定义plot菜单项 uimenu(hplot,'Label','Sine Wave','Call',... ['t=-pi:pi/20:pi;','h0=plot(t,sin(t));',...

1

实验6

'set(hlr,''Enable'',''on'');',... 'set(hlg,''Enable'',''on'');',... 'set(hlb,''Enable'',''on'');']);

uimenu(hplot,'Label','Cosine Wave','Call',... ['t=-pi:pi/20:pi;','h0=plot(t,cos(t));',... 'set(hlr,''Enable'',''on'');',... 'set(hlg,''Enable'',''on'');',... 'set(hlb,''Enable'',''on'');']);

uimenu(hplot,'Label','&Exit','Call','close(gcf)'); hc=uimenu(gcf,'Label','&Color'); %定义Color菜单项 hw=uimenu(hc,'Label','&Window Color');

uimenu(hw,'Label','&Red','Call','set(gcf,''Color'',''r'');'); uimenu(hw,'Label','&Green','Call','set(gcf,''Color'',''g'');'); uimenu(hw,'Label','&Blue','Call','set(gcf,''Color'',''b'');'); hl=uimenu(hc,'Label','&Line Color','Separator','on'); hlr=uimenu(hl,'Label','&Red','Call',...

'set(h0,''Color'',''r'');','Enable','off'); hlg=uimenu(hl,'Label','&Green','Call',... 'set(h0,''Color'',''g'');','Enable','off'); hlb=uimenu(hl,'Label','&Blue','Call',... 'set(h0,''Color'',''b'');','Enable','off');

2. hf=figure('menubar','none','name','图形演示',...

'numbertitle','off'); %定义图形窗口

set(gcf,'unit','normalized','posi',[0.2,0.3,0.55,0.36]); axes('posi',[0.05,0.15,0.55,0.7]); %定义坐标轴

uicontrol(gcf,'style','text','unit','normalized',... %定义静态文本 'posi',[0.63,0.85,0.1,0.1],'string','参 数 a',... 'horizontal','center');

uicontrol(gcf,'style','text','unit','normalized',...

2

实验6

'posi',[0.63,0.65,0.1,0.1],'string','参 数 b',... 'horizontal','center');

uicontrol(gcf,'style','text','unit','normalized',... 'posi',[0.63,0.45,0.1,0.1],'string','参 数 n',... 'horizontal','center');

ha=uicontrol(gcf,'style','edit','back','w',... %定义编辑框 'unit','normalized', 'posi',[0.80,0.85,0.15,0.1]); hb=uicontrol(gcf,'style','edit','back','w',...

'unit','normalized','posi',[0.80,0.65,0.15,0.1]); hn=uicontrol(gcf,'style','edit','back','w',...

'unit','normalized','posi',[0.80,0.45,0.15,0.1]);

uicontrol(gcf,'style','push','unit','normalized',... %定义按钮 'posi',[0.61,0.15,0.15,0.15],'string','绘 图','call',COMM); uicontrol(gcf,'style','push','unit','normalized',... 'posi',[0.80,0.15,0.15,0.15],'string','关 闭','call','close(gcf)');

COMM=['a=str2num(get(ha,''string''));',... %绘图 'b=str2num(get(hb,''string''));',... 'n=str2num(get(hn,''string''));',... 'theta=0:0.01:2*pi;',... 'rho=a*cos(b+n*theta);',... 'polar(theta,rho);'];

改变参数a,如图所示

3

实验6

改变参数b,如图所示

改变参数n,如图所示

4

实验6

5

搜索更多关于: 实验6 图形用户界面设计  的文档
实验6 图形用户界面设计 .doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c3e3hf4unf638ccg96p7d_1.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top