Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lab 2: MATLAB之基本繪圖功能. 二維X-Y座標圖 plot 、 plot(x) 、 plot(x,y) 、 plot(x,y,’ ‘) loglog 、 semilogx 、 semilogy, logspace x=[1:1:5]; y=[1,4,9,16,25]; plot(x,y,’r+’);grid.

Similar presentations


Presentation on theme: "Lab 2: MATLAB之基本繪圖功能. 二維X-Y座標圖 plot 、 plot(x) 、 plot(x,y) 、 plot(x,y,’ ‘) loglog 、 semilogx 、 semilogy, logspace x=[1:1:5]; y=[1,4,9,16,25]; plot(x,y,’r+’);grid."— Presentation transcript:

1 Lab 2: MATLAB之基本繪圖功能

2 二維X-Y座標圖 plot 、 plot(x) 、 plot(x,y) 、 plot(x,y,’ ‘) loglog 、 semilogx 、 semilogy, logspace x=[1:1:5]; y=[1,4,9,16,25]; plot(x,y,’r+’);grid loglog(x,y);grid polar(Θ,ρ) x=0:(pi/18):(2*pi); y=1+cos(x); polar(x,y);

3 plot 相關參數及繪圖視窗應用 whitebg ~ for MATLAB 4.x graphic window –4.2 ~ Edit  Copy Options –5.0 ~ File  Preferences  Copying Options 顏色、形式 –y( 黃 ) 、 m( 洋紅 ) 、 c( 青 ) 、 r( 紅 ) –g( 綠 ) 、 b( 藍 ) 、 w( 白 ) 、 k( 黑 ) –. 、 o 、 x 、 + 、 * –-( 實線 ) 、 :( 點線 ) 、 -.( 長點線 ) 、 --( 虛線 )

4 標題說明 title(‘string’) title(‘This plot is a test!’); xlabel(‘string’) 、 ylabel(‘string’) xlabel(‘time(second)’); ylabel(‘height(meter)’); text(x0,y0,’string’) 、 gtext(‘string’) text(2,4,‘It is here’); gtext(‘use your mouse to put the text!’); grid

5 圖形顯示控制 axis –axis([Xmin Xmax Ymin Ymax]) 、 axis(‘normal‘) 、 axis(‘square’) – 輪流設定為設定範圍或自動調整 hold –hold 、 hold on 、 hold off shg 、 clg subplot(mnp)

6 MATLAB程式撰寫入門

7 .M file 簡介及其他 變數名稱 = 起始值 : 遞增值 : 終止值 函式 M file –function 、 macro % ~註解 流程控制 –for end –while 、 if , elself , else –break , pause , return

8 delt_ang=pi/18; start_ang=0; end_ang=2*pi; offset=2.0; i=0 for ang=start_ang:delt_ang:end_ang, i=i+1; xrad(i)=ang; x(i)=ang*180./pi; y(i)=offset+cos(ang); end plot(x,y); grid; pause; loglog(x,y); grid; pause; polar(xrad,y);

9 練習作業 仿照前一頁程式,寫一 matlab 程式,劃出函數 其中 從 0 度到 360 度


Download ppt "Lab 2: MATLAB之基本繪圖功能. 二維X-Y座標圖 plot 、 plot(x) 、 plot(x,y) 、 plot(x,y,’ ‘) loglog 、 semilogx 、 semilogy, logspace x=[1:1:5]; y=[1,4,9,16,25]; plot(x,y,’r+’);grid."

Similar presentations


Ads by Google