Presentation is loading. Please wait.

Presentation is loading. Please wait.

Matlab 二維、三維圖形篇.

Similar presentations


Presentation on theme: "Matlab 二維、三維圖形篇."— Presentation transcript:

1 Matlab 二維、三維圖形篇

2 二維 x-y 座標圖 plot(x,y,’CLM’)將已知的點繪出,C為顏色,L為曲線格式,M為線標
loglog(x,y)其座標軸皆以對數比表示 semilogx(x,y)其x軸以對數比例表示 polar(θ,ρ)用極座標來繪圖,θ為角 度,ρ為大小

3 強化圖形之說明 title(‘string’):以string 為標題文字 xlabel(‘string’):x軸上說明文字
ylabel(‘string’):y軸上說明文字 grid:在座標上畫格線

4 x=linspace(0,2*pi) plot(x,sin(x),'b-o',x,cos(x),'g--+',x,sin(x)+cos(x),'r:*') title('y-x') xlabel('x') ylabel('y') Legend('sin(x)','cos(x)','sin(x)+cos(x)') grid

5

6 給定座標繪製2D曲線 x=[3 2 1 0 -1 -2 -3], y=[14 4 -2 -4 -2 4 14] plot (x,y)

7 常用XYZ立體繪圖命令

8 plot3(x,y,z)分別是代表X Y Z 的立體座標
t=linspace(0,10*pi,500) %在0到10pi取500個點 plot3(t.*sin(t),t.*cos(t),t,t.*sin(t),t.*cos(t),-t)

9

10 給定座標繪製3D曲線 x=[ ], y=[ ], z=[ ] plot3 (x,y,z) 所繪之3D曲線圖為:

11 3D曲線影像重建 已知某曲線在yz及xy平面的投影為左圖,則可重建之3D曲線為右圖:

12 基本XYZ立體繪圖命令 mesh可畫出立體網狀圖 surf可畫出立體曲面圖 兩者產生的圖形都會依高度而有不同顏色

13 由函數形成的立體網狀圖: x=linspace(-2, 2, 25); % 在x軸上取25點
y=linspace(-2, 2, 25); % 在y軸上取25點 [xx,yy]=meshgrid(x, y); % xx和yy都是25x25的矩陣 zz=xx.*exp(-xx.^2-yy.^2); % 計算函數值,zz也是21x21的矩陣 mesh(xx, yy, zz); % 畫出立體網狀圖 surf(xx, yy, zz); % 畫出立體曲面圖

14

15 peaks函數 可產生一個凹凸有致的曲面 包含了三個局部極大點及三個局部極小點

16 peaks

17 Meshz會將圖加上[圍裙] [x,y,z]=peaks; meshz(x,y,z); axis tight; %塞滿整個圖軸

18 waterfall 可在x方向或y方向產生水流效果
[x,y,z]=peaks; waterfall(x,y,z); axis tight;

19 meshc同時畫出網狀圖與等高線 [x,y,z]=peaks; meshc(x,y,z); axis tight; %塞滿整個圖軸

20 surfc同時畫出曲面圖與等高線 [x,y,z]=peaks; surfc(x,y,z); axis tight;


Download ppt "Matlab 二維、三維圖形篇."

Similar presentations


Ads by Google