版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、实验7 图形句柄的应用、可视化界面的设计一、实验目的1、掌握图形句柄的应用;2、采用figure, uimenu, uicontextmenu函数设置窗口界面;3、掌握可视化界面GUI的设计应用。二、实验内容1、运行以下程序:(1)体会pause、close命令的作用。Pause作用是使程序暂停,直至用户按任意一个按键.Close作用是关闭图形窗口(2)语句9的作用是什么?将标题颜色变为红色,字号大小25。(3)12语句的作用是什么?获得屏幕尺寸(4)13语句的作用是什么?修改其中的属性值,看运行结果如何?设置窗口在windos界面的位置,及窗口大小。(5)修改14语句中的属性值,看运行结果如
2、何?分别代表距离该窗口边线的上下左右的距离百分比(6)16,17语句的作用是什么?设置x,y坐标轴的范围。x=-5:0.1:5; % 1h=plot(x,3*x+sin(x)-exp(x); % 2set(h,'color','r','linestyle',':','linewidth',5) % 3title('曲线图','color','g') % 4pause % 5set(get(gca,'xlabel'),'string',&
3、#39;x-axis'); % 6set(get(gca,'ylabel'),'string','y-axis'); % 7set(get(gca,'zlabel'),'string','z-axis'); % 8set(get(gca,'title'),'color','r','fontsize',25); % 9pause % 10close % 11scrsz = get(0,'ScreenSize');
4、% 12set(gcf,'Position',20 100 scrsz(3)/2 scrsz(4)/2) % 13set(gca,'position',0.1 0.1 0.8 0.8) % 14h=plot(x,3*x+sin(x)-exp(x) % 15set(gca,'xlim',-10,10); % 16set(gca,'ylim',-100,30); % 172、采用figure, uimenu, uicontextmenu函数设置窗口界面如图1:(1)隐藏原菜单条,将标题命名为:运行结果。(2)背景设为黄色。(3)建立菜
5、单“仿真”。在“仿真”菜单下建立“绘制曲线sin(x)”以及“绘制曲线cos(x)”并能实现相应的曲线绘制功能。(4)建立一个与sin(x)、cos(x)相联系的快捷菜单,用以控制曲线的线型(实线,虚线)、线宽(加宽,变细)以及曲线颜色(红色,绿色)。(5)建立关闭窗口菜单。图 1figure('Menubar', 'none', 'Name', 'ÔËÐнá¹û','NumberTitle', 'off', '
6、;color','y') ;hplot=uimenu(gcf, 'label' , '·ÂÕæ' );ss='UIContextMenu' uimenu(hplot, 'label' , '»æÖÆÇúÏßsin(x)' , 'Call' , 'x=0:pi/100:6*pi;y=sin(x);line=plot(y);set(line,ss,jhf
7、);' );uimenu(hplot, 'label' , '»æÖÆÇúÏßcos(x)' , 'Call' , 'x=0:pi/100:6*pi;y=cos(x);line=plot(y);set(line,ss,jhf);' );uimenu(gcf,'label','¹Ø±Õ´°¿Ú','Callback',&
8、#39;close(gcf)');jhf=uicontextmenu; xx=uimenu(jhf,'Label','ÏßÐÍ'); xk=uimenu(jhf,'Label','Ïß¿í'); ys=uimenu(jhf,'Label','ÑÕÉ«'); uimenu(xx,'Label','ʵÏß'
9、;,'Call','set(line,''LineStyle'',''-'');');uimenu(xx,'Label','ÐéÏß','Call','set(line,''LineStyle'','':'');'); uimenu(xk,'Label','¼Ó¿í
10、9;,'Call','set(line,''LineWidth'',5);'); uimenu(xk,'Label','±äϸ','Call','set(line,''LineWidth'',0.5);'); uimenu(ys,'Label','ºìÉ«','Call','set(line,'
11、;'Color'',''r'');'); uimenu(ys,'Label','ÂÌÉ«','Call','set(line,''Color'',''g'');'); set(line,'UIContextMenu',jhf)3、利用可视化界面GUI设计环境完成图2的界面图:(只给出相关的程序段)(1)将标题命名为result(2)建立“仿真”菜单、
12、“关闭窗口”菜单:仿真:在仿真菜单下建立绘制曲线sin(x)、绘制曲线cos(x)子菜单并实现绘图功能。关闭窗口:实现关闭窗口功能。(3)建立快捷菜单,实现以下功能:在网格菜单下设计子菜单:加网格,去网格,并实现其功能;在坐标菜单下设计子菜单:标注坐标(x轴,y轴),去标注坐标;在标题菜单下设计子菜单:加标题(仿真曲线,红色字体大小为20),去标题。(4)在设计菜单时,注意复选框spearator above this item、enable this item在程序运行中的作用。spearator above this item作用为分割线enable this item作用是是菜单生效 f
13、unction varargout = mat(varargin)% MAT MATLAB code for mat.fig% MAT, by itself, creates a new MAT or raises the existing% singleton*.% H = MAT returns the handle to a new MAT or the handle to% the existing singleton*.% MAT('CALLBACK',hObject,eventData,handles,.) calls the local% function nam
14、ed CALLBACK in MAT.M with the given input arguments.% MAT('Property','Value',.) creates a new MAT or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before mat_OpeningFcn gets called. An% unrecognized property name or invalid valu
15、e makes property application% stop. All inputs are passed to mat_OpeningFcn via varargin.% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one% instance to run (singleton)".% See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help mat %
16、 Last Modified by GUIDE v2.5 20-Apr-2012 05:44:04 % Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, . 'gui_Singleton', gui_Singleton, . 'gui_OpeningFcn', mat_OpeningFcn, . 'gui_OutputFcn', mat_OutputFcn, . 'gui_La
17、youtFcn', , . 'gui_Callback', );if nargin && ischar(varargin1) gui_State.gui_Callback = str2func(varargin1);end if nargout varargout1:nargout = gui_mainfcn(gui_State, varargin:);else gui_mainfcn(gui_State, varargin:);end% End initialization code - DO NOT EDIT % - Executes just be
18、fore mat is made visible.function mat_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin
19、command line arguments to mat (see VARARGIN) % Choose default command line output for mathandles.output = hObject; % Update handles structureguidata(hObject, handles); % UIWAIT makes mat wait for user response (see UIRESUME)% uiwait(handles.figure1); % - Outputs from this function are returned to th
20、e command line.function varargout = mat_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % G
21、et default command line output from handles structurevarargout1 = handles.output; % -function Untitled_1_Callback(hObject, eventdata, handles)% hObject handle to Untitled_1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see
22、 GUIDATA) % -function exit_Callback(hObject, eventdata, handles)% hObject handle to exit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)exit % -function grid_Callback(hObject, eventdata, handles)% hObject handle
23、 to grid (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % -function Untitled_10_Callback(hObject, eventdata, handles)% hObject handle to Untitled_10 (see GCBO)% eventdata reserved - to be defined in a future ve
24、rsion of MATLAB% handles structure with handles and user data (see GUIDATA) % -function Untitled_13_Callback(hObject, eventdata, handles)% hObject handle to Untitled_13 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUI
25、DATA) % -function sin_Callback(hObject, eventdata, handles)% hObject handle to sin (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)x=0:0.01*pi:6*pi;y=sin(x);plot(x,y,'b') % -function cos_Callback(hObject,
26、 eventdata, handles)% hObject handle to cos (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)x=0:0.01*pi:6*pi;y=cos(x);plot(x,y,'b') % -function at_Callback(hObject, eventdata, handles)% hObject handle to
27、at (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)title('·ÂÕæÇúÏß','color','r','Fontsize',20) % -function dt_Callback(hObject, eventdata, h
28、andles)% hObject handle to dt (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)title(' ') % -function aa_Callback(hObject, eventdata, handles)% hObject handle to aa (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)xlabel('xÖ
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 猎户座介绍教学课件
- 狼性团队培训
- 2026年智能遮阳风雨感应器项目公司成立分析报告
- 2025年西藏中考语文真题卷含答案解析
- 《铁路路基工程施工质量验收标准》试题含答案
- 物业公司保洁部年终工作总结
- 2025年注册安全工程师安全评价专项试卷(含答案)
- 污水处理知识试题题库及答案
- 《2025年企业人力资源管理师(三级)技能操作试卷含答案》
- 楼承板施工方案
- 内镜院感培训课件
- 2026中征(北京)征信有限责任公司招聘13人考试题库附答案
- 期末重点易错知识点复习(课件)-2025-2026学年一年级上册数学北师大版
- 2026年杨凌职业技术学院单招职业技能考试题库含答案详解
- 2025云南昆明元朔建设发展有限公司第二批收费员招聘9人笔试考试参考题库及答案解析
- 国开本科《国际法》期末真题及答案2025年
- 2025年榆林神木市信息产业发展集团招聘备考题库(35人)及完整答案详解1套
- 2025新疆能源(集团)有限责任公司共享中心招聘备考题库(2人)带答案详解(完整版)
- 2026年中考作文备考之10篇高分考场范文
- 2025年自考专业(学前教育)真题附完整答案
- 比亚迪维修试车协议书
评论
0/150
提交评论