版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、1-32是:圖形應(yīng)用篇33-66是:界面設(shè)計(jì)篇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:?jiǎn)蝹€(gè)軸窗口顯示多個(gè)圖形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)力, 北京氣象臺(tái), 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)取最后一個(gè)點(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)取下一個(gè)點(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)取最后一個(gè)點(diǎn));but=1;while but=1 xi,yi,but=ginput(1); plot(xi,yi,bo) n=n+1; disp(單擊鼠標(biāo)左鍵點(diǎn)取下一個(gè)點(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:勞倫茲非線形方程的無序活動(dòng)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等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(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年度EPS環(huán)保設(shè)施施工合同
- 凝血系統(tǒng)課件教學(xué)課件
- 2024年度婚姻心理咨詢服務(wù)協(xié)議
- 2024年全球互聯(lián)網(wǎng)金融服務(wù)協(xié)議
- 2024年廢舊書籍收購(gòu)協(xié)議
- 2024代理授權(quán)協(xié)議合同租房合同模板
- 洗手絹課件教學(xué)課件
- 2024年度通信網(wǎng)絡(luò)建設(shè)與維護(hù)合同
- 2024機(jī)械使用合同
- (2024版)網(wǎng)絡(luò)安全系統(tǒng)設(shè)計(jì)與實(shí)施合同
- 冬季傳染病預(yù)防-(課件)-小學(xué)主題班會(huì)課件
- 2024年秋新北師大版數(shù)學(xué)一年級(jí)上冊(cè)課件 第四單元 一起做游戲
- 云南省昆明市五華區(qū)2022-2023學(xué)年九年級(jí)上學(xué)期期中檢測(cè)物理試題
- 人教版四年級(jí)上冊(cè)美術(shù)教案設(shè)計(jì)-表格
- 居間人土方合同協(xié)議書
- 銀行保安服務(wù)外包采購(gòu)項(xiàng)目投標(biāo)方案技術(shù)方案(技術(shù)方案)
- 社會(huì)工作方法 個(gè)案工作 個(gè)案所需表格
- 2024屆中國(guó)一汽全球校園招聘高頻500題難、易錯(cuò)點(diǎn)模擬試題附帶答案詳解
- 2024大連機(jī)場(chǎng)招聘109人高頻500題難、易錯(cuò)點(diǎn)模擬試題附帶答案詳解
- 2024新教材高中政治 第二單元 經(jīng)濟(jì)發(fā)展與社會(huì)進(jìn)步 第三課 我國(guó)的經(jīng)濟(jì)發(fā)展 3.1 堅(jiān)持新發(fā)展理念教學(xué)設(shè)計(jì) 部編版必修2
- JGJ46-2005施工現(xiàn)場(chǎng)臨時(shí)用電安全技術(shù)規(guī)范專題理論考試試題
評(píng)論
0/150
提交評(píng)論