?? ch2_5.htm
字號:
<! Made by Html Translation Ver 1.0>
<HTML>
<HEAD>
<TITLE> 簡易繪圖 </TITLE>
</HEAD>
<BODY BACKGROUND="bg0000.gif" tppabs="http://166.111.167.223/computer/cai/matlabjc/img/bg0000.gif">
<FONT COLOR="#0000FF">
<H1>2.5 簡易繪圖</H1>
</FONT>
<HR>
<P>
MATLAB 的繪圖功能很強,我們先從最簡單的二維繪圖指令<FONT COLOR=#FF0000>plot</FONT>介紹起。<FONT COLOR=#FF0000>plot</FONT>是用來劃函數x對函數y的二維圖,例如要劃
出<I> y = sin (x), 0 x 2π</I>。<FONT COLOR=#FF0000>plot</FONT>可以在一個圖上劃數條曲線,且以不同的符號及顏色來標示曲線,其指令見線上
說明<FONT COLOR=#FF0000>help plot</FONT>。如要在x及y軸及全圖加注說明,則可利用指令<FONT COLOR=#FF0000>xlabel</FONT>,
<FONT COLOR=#FF0000>ylabel</FONT>, <FONT COLOR=#FF0000>title</FONT>,其指令見線上說明<FONT COLOR=#FF0000>help xlabel</FONT>, <FONT COLOR=#FF0000>help
ylabel</FONT>, <FONT COLOR=#FF0000>help title</FONT>。三維圖的指令為<FONT COLOR=#FF0000>plot3</FONT>,其指令見線上說明<FONT COLOR=#FF0000>help plot3</FONT>。此外二維圖及三維圖皆可使用指令<FONT COLOR=#FF0000>grid</FONT>
加上格線。MATLAB會將繪圖結果展示在另一個視窗稱為<B>MATLAB Figure Windows</B>,如果你看不到此視窗,
別擔心它只是被蓋住,可以進入<B>Windows</B>再選擇<B>Figure</B>。接著我們就來看以下的例子
<P>
<FONT COLOR=#FF0000>>> v1=linspace(0,2*pi,20); v2=sin(v1);
% 建立 v1 及 v2 陣列</FONT>
<P>
<FONT COLOR=#FF0000>>> plot(v1,v2) % 利用 plot,輸入的變數為
x 軸接著的變數為 y 軸</FONT>
<P>
<FONT COLOR=#FF0000>>> v3=cos(v1); % 建立 v3 陣列</FONT>
<P>
<FONT COLOR=#FF0000>>> plot(v1,v2,v1,v3) % 劃二條曲線,一條代表
v1-v2 函數關系 </FONT>
<P>
<FONT COLOR=#FF0000>%一條代表 v1-v3 函數關系</FONT>
<P>
<FONT COLOR=#FF0000>>> plot(v1,v2,v1,v2,'+') % 一樣劃二條曲線,不過第二條曲線以符號
+ 標示</FONT>
<P>
<FONT COLOR=#FF0000>>> plot(v1,v2,v1,v2.*v3,'--') % 劃二條曲線,一條代表
v1-v2 函數關系,一條</FONT>
<P>
<FONT COLOR=#FF0000>% 代表 v1-(v2.*v3) 函數關系且以符號'標示</FONT>
<P>
<FONT COLOR=#FF0000>>> xlabel('x-axis') % 加上 x 軸的說明,在二個單引號
' 之間鍵入文字的說明</FONT>
<P>
<FONT COLOR=#FF0000>>> ylabel('y-axis') % 加上 y 軸的說明</FONT>
<P>
<FONT COLOR=#FF0000>>> title('2D plot') % 加上圖的說明</FONT>
<P>
<FONT COLOR=#FF0000>>> plot3(v2,v3,v1), grid % 將 v2-v1-v3
函數關系分別以x軸y軸及z軸劃,并加上格線<BR>
</FONT><HR>
<A HREF="ch2_4_5.htm" tppabs="http://166.111.167.223/computer/cai/matlabjc/ch2_4_5.htm"><IMG SRC="lastpage.gif" tppabs="http://166.111.167.223/computer/cai/matlabjc/img/lastpage.gif" BORDER=0></A>
<A HREF="ch2_6.htm" tppabs="http://166.111.167.223/computer/cai/matlabjc/ch2_6.htm"><IMG SRC="nextpage-1.gif" tppabs="http://166.111.167.223/computer/cai/matlabjc/img/nextpage.gif" BORDER=0 HSPACE=10></A>
<A HREF="index.html" tppabs="http://166.111.167.223/computer/cai/matlabjc/index.html"><IMG SRC="outline-1.gif" tppabs="http://166.111.167.223/computer/cai/matlabjc/img/outline.gif" BORDER=0 HSPACE=6></A><BR>
<FONT SIZE=2 COLOR=#AA55FF> 上一頁 下一頁 講義大綱 </FONT>
</BODY>
</HTML>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -