1 / 20

Matlab

Matlab. 二維、三維圖形篇. 二維 x-y 座標圖. plot ( x,y, ’ CLM ’ )將已知的點繪出 ,C 為顏色 ,L 為曲線格式 ,M 為線標 loglog ( x,y )其座標軸皆以對數比表示 semilogx ( x,y )其 x 軸以對數比例表示 polar ( θ,ρ )用極座標來繪圖 ,θ 為角 度 ,ρ 為大小. title( ‘ string ’ ) : 以 string 為標題文字 xlabel( ‘ string ’ ) : x 軸上說明文字 ylabel( ‘ string ’ ) : y 軸上說明文字

Download Presentation

Matlab

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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. 給定座標繪製2D曲線 • x=[3 2 1 0 -1 -2 -3], y=[14 4 -2 -4 -2 4 14] • plot (x,y) • 所繪之2D曲線為:

  6. 常用XYZ立體繪圖命令

  7. 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)

  8. 給定座標繪製3D曲線 • x=[3 2 1 0 -1 -2 -3], y=[2.9 1.9 0.9 -0.1 -1.1 -2.1 -3.1], z=[14 4 -2 -4 -2 4 14] • plot3 (x,y,z) • 所繪之3D曲線圖為:

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

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

  11. 由函數形成的立體網狀圖: • 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); % 畫出立體曲面圖

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

  13. peaks

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

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

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

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

More Related