下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
PAGE29第10章MATLAB圖形用戶界面設(shè)計(jì)第10章MATLAB圖形用戶界面設(shè)計(jì)例10-1screen=get(0,'ScreenSize');W=screen(3);H=screen(4);figure('Color',[1,1,1],'Position',[0.2*H,0.2*H,0.5*W,0.3*H],...'Name','圖形演示系統(tǒng)','NumberTitle','off','MenuBar','none');%定義Plot菜單項(xiàng)hplot=uimenu(gcf,'Label','&Plot');uimenu(hplot,'Label','SineWave','Call',...['t=-pi:pi/20:pi;','plot(t,sin(t));',...'set(hgon,''Enable'',''on'');',...'set(hgoff,''Enable'',''on'');',...'set(hbon,''Enable'',''on'');',...'set(hboff,''Enable'',''on'');']);uimenu(hplot,'Label','CosineWave','Call',...['t=-pi:pi/20:pi;','plot(t,cos(t));',...'set(hgon,''Enable'',''on'');',...'set(hgoff,''Enable'',''on'');',...'set(hbon,''Enable'',''on'');',...'set(hboff,''Enable'',''on'');']);%定義Option菜單項(xiàng)hoption=uimenu(gcf,'Label','&Option');hgon=uimenu(hoption,'Label','&Gridon',...'Call','gridon','Enable','off');hgoff=uimenu(hoption,'Label','&Gridoff',...'Call','gridoff','Enable','off');hbon=uimenu(hoption,'Label','&Boxon',...'separator','on','Call','boxon','Enable','off');hboff=uimenu(hoption,'Label','&Boxoff',...'Call','boxoff','Enable','off');hwincor=uimenu(hoption,'Label','&WindowColor','Separator','on');uimenu(hwincor,'Label','&Red','Accelerator','r',...'Call','set(gcf,''Color'',''r'');');uimenu(hwincor,'Label','&Blue','Accelerator','b',...'Call','set(gcf,''Color'',''b'');');uimenu(hwincor,'Label','&Yellow','Call',...'set(gcf,''Color'',''y'');');uimenu(hwincor,'Label','&White','Call',...'set(gcf,''Color'',''w'');');%定義Quit菜單項(xiàng)uimenu(gcf,'Label','&Quit','Call','close(gcf)');例10-2x=0:pi/100:2*pi;y=2*sin(5*x).*sin(x);hl=plot(x,y);hc=uicontextmenu; %建立快捷菜單hls=uimenu(hc,'Label','線型'); %建立菜單項(xiàng)hlw=uimenu(hc,'Label','線寬');uimenu(hls,'Label','虛線','Call','set(hl,''LineStyle'','':'');');uimenu(hls,'Label','實(shí)線','Call','set(hl,''LineStyle'',''-'');');uimenu(hlw,'Label','加寬','Call','set(hl,''LineWidth'',2);');uimenu(hlw,'Label','變細(xì)','Call','set(hl,''LineWidth'',0.5);');set(hl,'UIContextMenu',hc); %將該快捷菜單和曲線對(duì)象聯(lián)系起來例10-3hf=figure('Color',[0,1,1],'Position',[100,200,400,200],...'Name','數(shù)制轉(zhuǎn)換','NumberTitle','off','MenuBar','none');uicontrol(hf,'Style','Text','Position',[80,160,40,20],...'Horizontal','center','String','輸入框','Back',[0,1,1])uicontrol(hf,'Style','Text','Position',[280,160,40,20],...'Horizontal','center','String','輸出框','Back',[0,1,1])uicontrol(hf,'Style','Frame','Position',[20,65,165,90],'Back',[1,1,0])uicontrol(hf,'Style','Text','Position',[25,110,85,25],...'Horizontal','center','String','十進(jìn)制數(shù)','Back',[1,1,0])uicontrol(hf,'Style','Text','Position',[25,75,85,25],...'Horizontal','center','String','2~16進(jìn)制','Back',[1,1,0])he1=uicontrol(hf,'Style','Edit','Position',[100,115,60,25],...'Back',[0,1,0]);he2=uicontrol(hf,'Style','Edit','Position',[100,80,60,25],...'Back',[0,1,0]);uicontrol(hf,'Style','Frame','Position',[215,65,165,90],'Back',[1,1,0])ht=uicontrol(hf,'Style','Text','Position',[255,95,90,30],...'Horizontal','center','Back',[0,1,0]);COMM=['n=str2num(get(he1,''String''));',...'b=str2num(get(he2,''String''));',...'dec=trdec(n,b);','set(ht,''string'',dec);'];uicontrol(hf,'Style','Push','Position',[55,20,90,25],...'String','轉(zhuǎn)換','Call',COMM)uicontrol(hf,'Style','Push','Position',[255,20,90,30],...'String','退出','Call','close(hf)')trdec.m函數(shù)文件如下:functiondec=trdec(n,b)ch1='0123456789ABCDEF'; %十六進(jìn)制的16個(gè)符號(hào)k=1;whilen~=0 %不斷除某進(jìn)制基數(shù)取余直到商為0p(k)=rem(n,b);n=fix(n/b);k=k+1;endk=k-1;strdec='';whilek>=1 %形成某進(jìn)制數(shù)的字符串kb=p(k);strdec=strcat(strdec,ch1(kb+1:kb+1));k=k-1;enddec=strdec;例10-4clf;set(gcf,'Unit','normalized','Position',[0.2,0.3,0.55,0.30]);set(gcf,'Menubar','none','Name','圖形演示','NumberTitle','off');axes('Position',[0.05,0.15,0.55,0.7]);uicontrol(gcf,'Style','text','Unit','normalized',...'Posi',[0.63,0.85,0.2,0.1],'String',...'輸入繪圖命令','Horizontal','center');hedit=uicontrol(gcf,'Style','edit','Unit','normalized',...'Posi',[0.63,0.15,0.2,0.68],...'Max',2);%Max取2,使Max-Min>1,從而允許多行輸入hpopup=uicontrol(gcf,'Style','popup','Unit','normalized',...'Posi',[0.85,0.8,0.15,0.15],'String',...'Spring|Summer|Autumn|Winter','Call',...'comm(hedit,hpopup,hlist)');hlist=uicontrol(gcf,'Style','list','Unit','normalized',...'Posi',[0.85,0.55,0.15,0.25],'String',...'Gridon|Gridoff|Boxon|Boxoff','Call',...'comm(hedit,hpopup,hlist)');hpush1=uicontrol(gcf,'Style','push','Unit','normalized',...'Posi',[0.85,0.35,0.15,0.15],'String',...'繪圖','Call','comm(hedit,hpopup,hlist)');uicontrol(gcf,'Style','push','Unit','normalized',...'Posi',[0.85,0.15,0.15,0.15],'String',...'關(guān)閉','Call','closeall');comm.m函數(shù)文件如下:functioncomm(hedit,hpopup,hlist)com=get(hedit,'String');n1=get(hpopup,'Value');n2=get(hlist,'Value');if~isempty(com)%編輯框輸入非空時(shí)eval(com');%執(zhí)行從編輯框輸入的命令chpop={'spring','summer','autumn','winter'};chlist={'gridon','gridoff','boxon','boxoff'};
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024-2030年中國(guó)地產(chǎn)綠化商業(yè)計(jì)劃書
- 2024-2030年中國(guó)咸菜市場(chǎng)發(fā)展前景調(diào)研與投資策略分析報(bào)告
- 2024-2030年中國(guó)印花熱熔膠融資商業(yè)計(jì)劃書
- 2024年體育用品銷售租賃合同
- 滿洲里俄語職業(yè)學(xué)院《STEM課程教學(xué)與微課制作》2023-2024學(xué)年第一學(xué)期期末試卷
- 2024年兒童個(gè)性化教育服務(wù)聘請(qǐng)教師勞動(dòng)合同模板3篇
- 2024年房屋中介居間協(xié)議2篇
- 漯河醫(yī)學(xué)高等??茖W(xué)校《畫法幾何與土建制圖》2023-2024學(xué)年第一學(xué)期期末試卷
- 2025年銅川貨運(yùn)從業(yè)資格證模擬考試下載什么軟件
- 2024年標(biāo)準(zhǔn)格式個(gè)人等額本息貸款合同版B版
- 當(dāng)前臺(tái)海局勢(shì)分析課件
- 五金采購(gòu)工作總結(jié)
- 蘇教版三年級(jí)上冊(cè)解決問題的策略應(yīng)用題100題及答案
- 質(zhì)量管理中的流程改進(jìn)與優(yōu)化
- 成長(zhǎng)賽道-模板參考
- 室外晾衣棚施工方案
- 兒童健康管理服務(wù)總結(jié)分析報(bào)告
- 殯葬行業(yè)的風(fēng)險(xiǎn)分析
- 通信工程冬季施工安全培訓(xùn)
- 痛風(fēng)病科普講座課件
- 工作崗位風(fēng)險(xiǎn)評(píng)估報(bào)告
評(píng)論
0/150
提交評(píng)論