




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、1-32是:圖形應(yīng)用篇33-66是:界面設(shè)計篇67-84是:圖形處理篇85-100是:數(shù)值分析篇實(shí)例1:三角函數(shù)曲線(1)function shili01h0=figure(toolbar,none,. position,198 56 350 300,. name,實(shí)例01);h1=axes(parent,h0,. visible,off);x=-pi:0.05:pi;y=sin(x);plot(x,y);xlabel(自變量X);ylabel(函數(shù)值Y);title(SIN( )函數(shù)曲線);grid on實(shí)例2:三角函數(shù)曲線(2)function shili02h0=figure(toolb
2、ar,none,. position,200 150 450 350,. name,實(shí)例02);x=-pi:0.05:pi;y=sin(x)+cos(x);plot(x,y,-*r,linewidth,1);grid onxlabel(自變量X);ylabel(函數(shù)值Y);title(三角函數(shù));實(shí)例3:圖形的疊加function shili03h0=figure(toolbar,none,. position,200 150 450 350,. name,實(shí)例03);x=-pi:0.05:pi;y1=sin(x);y2=cos(x);plot(x,y1,. -*r,. x,y2,. -og)
3、;grid onxlabel(自變量X);ylabel(函數(shù)值Y);title(三角函數(shù));實(shí)例4:雙y軸圖形的繪制function shili04h0=figure(toolbar,none,. position,200 150 450 250,. name,實(shí)例04);x=0:900;a=1000;b=0.005;y1=2*x;y2=cos(b*x);haxes,hline1,hline2=plotyy(x,y1,x,y2,semilogy,plot);axes(haxes(1)ylabel(semilog plot);axes(haxes(2)ylabel(linear plot);實(shí)例
4、5:單個軸窗口顯示多個圖形function shili05h0=figure(toolbar,none,. position,200 150 450 250,. name,實(shí)例05);t=0:pi/10:2*pi;x,y=meshgrid(t);subplot(2,2,1)plot(sin(t),cos(t)axis equalsubplot(2,2,2)z=sin(x)-cos(y);plot(t,z)axis(0 2*pi -2 2)subplot(2,2,3)h=sin(x)+cos(y);plot(t,h)axis(0 2*pi -2 2)subplot(2,2,4)g=(sin(x)
5、.2)-(cos(y).2);plot(t,g)axis(0 2*pi -1 1)實(shí)例6:圖形標(biāo)注function shili06h0=figure(toolbar,none,. position,200 150 450 400,. name,實(shí)例06);t=0:pi/10:2*pi;h=plot(t,sin(t);xlabel(t=0到2pi,fontsize,16);ylabel(sin(t),fontsize,16);title(it從 0to2pi 的正弦曲線,fontsize,16)x=get(h,xdata);y=get(h,ydata);imin=find(min(y)=y);i
6、max=find(max(y)=y);text(x(imin),y(imin),. leftarrow最小值=,num2str(y(imin),. fontsize,16)text(x(imax),y(imax),. leftarrow最大值=,num2str(y(imax),. fontsize,16) 實(shí)例7:條形圖形function shili07h0=figure(toolbar,none,. position,200 150 450 350,. name,實(shí)例07);tiao1=562 548 224 545 41 445 745 512;tiao2=47 48 57 58 54 5
7、2 65 48;t=0:7;bar(t,tiao1)xlabel(X軸);ylabel(TIAO1值);h1=gca;h2=axes(position,get(h1,position);plot(t,tiao2,linewidth,3)set(h2,yaxislocation,right,color,none,xticklabel,)實(shí)例8:區(qū)域圖形function shili08h0=figure(toolbar,none,. position,200 150 450 250,. name,實(shí)例08);x=91:95;profits1=88 75 84 93 77;profits2=51 6
8、4 54 56 68;profits3=42 54 34 25 24;profits4=26 38 18 15 4;area(x,profits1,facecolor,0.5 0.9 0.6,. edgecolor,b,. linewidth,3)hold onarea(x,profits2,facecolor,0.9 0.85 0.7,. edgecolor,y,. linewidth,3)hold onarea(x,profits3,facecolor,0.3 0.6 0.7,. edgecolor,r,. linewidth,3)hold onarea(x,profits4,faceco
9、lor,0.6 0.5 0.9,. edgecolor,m,. linewidth,3)hold offset(gca,xtick,91:95)set(gca,layer,top)gtext(leftarrow第一季度銷量)gtext(leftarrow第二季度銷量)gtext(leftarrow第三季度銷量)gtext(leftarrow第四季度銷量)xlabel(年,fontsize,16);ylabel(銷售量,fontsize,16); 實(shí)例9:餅圖的繪制function shili09h0=figure(toolbar,none,. position,200 150 450 250,
10、. name,實(shí)例09);t=54 21 35; 68 54 35; 45 25 12; 48 68 45; 68 54 69;x=sum(t);h=pie(x);textobjs=findobj(h,type,text);str1=get(textobjs,string);val1=get(textobjs,extent);oldext=cat(1,val1:);names=商品一:;商品二:;商品三:;str2=strcat(names,str1);set(textobjs,string,str2)val2=get(textobjs,extent);newext=cat(1,val2:);
11、offset=sign(oldext(:,1).*(newext(:,3)-oldext(:,3)/2;pos=get(textobjs,position);textpos=cat(1,pos:);textpos(:,1)=textpos(:,1)+offset;set(textobjs,position,num2cell(textpos,3,2)實(shí)例10:階梯圖function shili10h0=figure(toolbar,none,. position,200 150 450 400,. name,實(shí)例10);a=0.01;b=0.5;t=0:10;f=exp(-a*t).*sin(b
12、*t);stairs(t,f)hold onplot(t,f,:*)hold offglabel=函數(shù)e-(alpha*t)sinbeta*t的階梯圖;gtext(glabel,fontsize,16)xlabel(t=0:10,fontsize,16)axis(0 10 -1.2 1.2)實(shí)例11:枝干圖function shili11h0=figure(toolbar,none,. position,200 150 450 350,. name,實(shí)例11);x=0:pi/20:2*pi;y1=sin(x);y2=cos(x);h1=stem(x,y1+y2);hold onh2=plot(
13、x,y1,r,x,y2,*g);hold offh3=h1(1);h2;legend(h3,y1+y2,y1=sin(x),y2=cos(x)xlabel(自變量X);ylabel(函數(shù)值Y);title(正弦函數(shù)與余弦函數(shù)的線性組合);實(shí)例12:羅盤圖function shili12h0=figure(toolbar,none,. position,200 150 450 250,. name,實(shí)例12);winddirection=54 24 65 84 256 12 235 62 125 324 34 254;windpower=2 5 5 3 6 8 12 7 6 14 10 8;rd
14、irection=winddirection*pi/180;x,y=pol2cart(rdirection,windpower);compass(x,y);desc=風(fēng)向和風(fēng)力, 北京氣象臺, 10月1日0:00到, 10月1日12:00;gtext(desc)實(shí)例13:輪廓圖function shili13h0=figure(toolbar,none,. position,200 150 450 250,. name,實(shí)例13);th,r=meshgrid(0:10:360)*pi/180,0:0.05:1);x,y=pol2cart(th,r);z=x+i*y;f=(z.4-1).(0.2
15、5);contour(x,y,abs(f),20)axis equalxlabel(實(shí)部,fontsize,16);ylabel(虛部,fontsize,16);h=polar(0 2*pi,0 1);delete(h)hold oncontour(x,y,abs(f),20)實(shí)例14:交互式圖形function shili14h0=figure(toolbar,none,. position,200 150 450 250,. name,實(shí)例14);axis(0 10 0 10);hold onx=;y=;n=0;disp(單擊鼠標(biāo)左鍵點(diǎn)取需要的點(diǎn));disp(單擊鼠標(biāo)右鍵點(diǎn)取最后一個點(diǎn));
16、but=1;while but=1 xi,yi,but=ginput(1); plot(xi,yi,bo) n=n+1; disp(單擊鼠標(biāo)左鍵點(diǎn)取下一個點(diǎn)); x(n,1)=xi; y(n,1)=yi;endt=1:n;ts=1:0.1:n;xs=spline(t,x,ts);ys=spline(t,y,ts);plot(xs,ys,r-);hold off實(shí)例14:交互式圖形function shili14h0=figure(toolbar,none,. position,200 150 450 250,. name,實(shí)例14);axis(0 10 0 10);hold onx=;y=;n
17、=0;disp(單擊鼠標(biāo)左鍵點(diǎn)取需要的點(diǎn));disp(單擊鼠標(biāo)右鍵點(diǎn)取最后一個點(diǎn));but=1;while but=1 xi,yi,but=ginput(1); plot(xi,yi,bo) n=n+1; disp(單擊鼠標(biāo)左鍵點(diǎn)取下一個點(diǎn)); x(n,1)=xi; y(n,1)=yi;endt=1:n;ts=1:0.1:n;xs=spline(t,x,ts);ys=spline(t,y,ts);plot(xs,ys,r-);hold off實(shí)例15:變換的傅立葉函數(shù)曲線function shili15h0=figure(toolbar,none,. position,200 150 450
18、250,. name,實(shí)例15);axis equalm=moviein(20,gcf);set(gca,nextplot,replacechildren)h=uicontrol(style,slider,position,. 100 10 500 20,min,1,max,20)for j=1:20 plot(fft(eye(j+16) set(h,value,j) m(:,j)=getframe(gcf);endclf;axes(position,0 0 1 1);movie(m,30)實(shí)例16:勞倫茲非線形方程的無序活動function shili15h0=figure(toolbar,
19、none,. position,200 150 450 250,. name,實(shí)例15);axis equalm=moviein(20,gcf);set(gca,nextplot,replacechildren)h=uicontrol(style,slider,position,. 100 10 500 20,min,1,max,20)for j=1:20 plot(fft(eye(j+16) set(h,value,j) m(:,j)=getframe(gcf);endclf;axes(position,0 0 1 1);movie(m,30)實(shí)例17:填充圖function shili17
20、h0=figure(toolbar,none,. position,200 150 450 250,. name,實(shí)例17);t=(1:2:15)*pi/8;x=sin(t);y=cos(t);fill(x,y,r)axis square offtext(0,0,STOP,. color,1 1 1,. fontsize,50,. horizontalalignment,center)例18:條形圖和階梯形圖function shili18h0=figure(toolbar,none,. position,200 150 450 250,. name,實(shí)例18);subplot(2,2,1)x
21、=-3:0.2:3;y=exp(-x.*x);bar(x,y)title(2-D Bar Chart)subplot(2,2,2)x=-3:0.2:3;y=exp(-x.*x);bar3(x,y,r)title(3-D Bar Chart)subplot(2,2,3)x=-3:0.2:3;y=exp(-x.*x);stairs(x,y)title(Stair Chart)subplot(2,2,4)x=-3:0.2:3;y=exp(-x.*x);barh(x,y)title(Horizontal Bar Chart) 實(shí)例19:三維曲線圖function shili19h0=figure(to
22、olbar,none,. position,200 150 450 400,. name,實(shí)例19);subplot(2,1,1)x=linspace(0,2*pi);y1=sin(x);y2=cos(x);y3=sin(x)+cos(x);z1=zeros(size(x);z2=0.5*z1;z3=z1;plot3(x,y1,z1,x,y2,z2,x,y3,z3)grid onxlabel(X軸);ylabel(Y軸);zlabel(Z軸);title(Figure1:3-D Plot)subplot(2,1,2)x=linspace(0,2*pi);y1=sin(x);y2=cos(x);
23、y3=sin(x)+cos(x);z1=zeros(size(x);z2=0.5*z1;z3=z1;plot3(x,z1,y1,x,z2,y2,x,z3,y3)grid onxlabel(X軸);ylabel(Y軸);zlabel(Z軸);title(Figure2:3-D Plot)實(shí)例20:圖形的隱藏屬性function shili20h0=figure(toolbar,none,. position,200 150 450 300,. name,實(shí)例20);subplot(1,2,1)x,y,z=sphere(10);mesh(x,y,z)axis offtitle(Figure1:Op
24、aque)hidden onsubplot(1,2,2)x,y,z=sphere(10);mesh(x,y,z)axis offtitle(Figure2:Transparent)hidden off實(shí)例21PEAKS函數(shù)曲線function shili21h0=figure(toolbar,none,. position,200 100 450 450,. name,實(shí)例21);x,y,z=peaks(30);subplot(2,1,1)x=x(1,:);y=y(:,1);i=find(y0.8&y-0.6&x0.8&y-0.6&xn,. m=m+1;,. i=1;,. end,. end,
25、. end);k2=uicontrol(parent,h0,. style,pushbutton,. position,180 100 50 30,. string,停止,. callback,. k=0;,. set(e1,string,m),. p=get(h,xdata);,. q=get(h,ydata);,. set(e2,string,p);,. set(e3,string,q);k3=uicontrol(parent,h0,. style,pushbutton,. position,280 100 50 30,. string,關(guān)閉,. callback,close);e1=ui
26、control(parent,h0,. style,edit,. position,60 30 60 20);t1=uicontrol(parent,h0,. style,text,. string,循環(huán)次數(shù),. position,60 50 60 20);e2=uicontrol(parent,h0,. style,edit,. position,180 30 50 20);t2=uicontrol(parent,h0,. style,text,. string,終點(diǎn)的X坐標(biāo)值,. position,155 50 100 20);e3=uicontrol(parent,h0,. style,
27、edit,. position,300 30 50 20);t3=uicontrol(parent,h0,. style,text,. string,終點(diǎn)的Y坐標(biāo)值,. position,275 50 100 20);實(shí)例33:曲線轉(zhuǎn)換按鈕h0=figure(toolbar,none,. position,200 150 450 250,. name,實(shí)例33);x=0:0.5:2*pi;y=sin(x);h=plot(x,y);grid onhuidiao=. if i=1,. i=0;,. y=cos(x);,. delete(h),. set(hm,string,正弦函數(shù)),. h=pl
28、ot(x,y);,. grid on,. else if i=0,. i=1;,. y=sin(x);,. set(hm,string,余弦函數(shù)),. delete(h),. h=plot(x,y);,. grid on,. end,. end;hm=uicontrol(gcf,style,pushbutton,. string,余弦函數(shù),. callback,huidiao);i=1;set(hm,position,250 20 60 20);set(gca,position,0.2 0.2 0.6 0.6)title(按鈕的使用)hold on實(shí)例34:柵格控制按鈕h0=figure(to
29、olbar,none,. position,200 150 450 250,. name,實(shí)例34);x=0:0.5:2*pi;y=sin(x);plot(x,y)huidiao1=. set(h_toggle2,value,0),. grid on,. ;huidiao2=. set(h_toggle1,value,0),. grid off,. ;h_toggle1=uicontrol(gcf,style,togglebutton,. string,grid on,. value,0,. position,20 45 50 20,. callback,huidiao1);h_toggle2=uicontrol(gcf,style,togglebutton,. string,grid off,. value,0,. position,20 20 50 20,. callback,huidiao2);set(gca,position,0.2 0.2 0.6 0.6)title(開關(guān)按鈕的使用)實(shí)例35:編輯框的使用h0=figure(toolbar,n
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年5G網(wǎng)絡(luò)通信設(shè)備采購合同標(biāo)準(zhǔn)
- 2025年醋酸乙烯酯項(xiàng)目建議書
- 2025年摻混肥項(xiàng)目合作計劃書
- 2025年本地網(wǎng)傳輸系統(tǒng)項(xiàng)目合作計劃書
- 強(qiáng)化法治教育促進(jìn)遵紀(jì)守法計劃
- 學(xué)習(xí)困難學(xué)生支持方案計劃
- 水庫管理與調(diào)度方案計劃
- 選擇合適的理財工具計劃
- 2025年金屬門窗及類似制品項(xiàng)目發(fā)展計劃
- 2025年中國顯控系統(tǒng)行業(yè)供需態(tài)勢、競爭格局及投資前景分析報告(智研咨詢)
- DL∕T 5810-2020 電化學(xué)儲能電站接入電網(wǎng)設(shè)計規(guī)范
- ISO9001、ISO14001和ISO45001質(zhì)量環(huán)境及職業(yè)健康安全三個體系的對比
- 大學(xué)生創(chuàng)新創(chuàng)業(yè)基礎(chǔ)教程(高校創(chuàng)新創(chuàng)業(yè)教育課程)全套教學(xué)課件
- 2024年內(nèi)蒙古交通職業(yè)技術(shù)學(xué)院單招職業(yè)技能測試題庫完整
- 天津和平區(qū)2024屆高三一模數(shù)學(xué)試題(解析版)
- 人教版高中物理必修二同步練習(xí)及答案
- 《行政倫理學(xué)教程(第四版)》課件 第7、8章?行政人格、行政組織倫理
- 2024年江蘇蘇??毓杉瘓F(tuán)有限公司招聘筆試沖刺題(帶答案解析)
- 工商聯(lián)業(yè)務(wù)工作培訓(xùn)
- 商業(yè)街消防安全培訓(xùn)
- 湖北省曾都區(qū)烏鴉山礦區(qū)建筑用輝綠巖礦礦產(chǎn)資源開發(fā)利用與生態(tài)復(fù)綠方案
評論
0/150
提交評論