matlab程式设计入门篇二维平面绘图内容摘要:
程式設計入門篇:二維平面繪圖 圖軸控制範例 1 (I) 畫出正弦波在 y 軸介於 0 和 1 的部份 範例 310: x = 0::4*pi。 % 起始與結束元素為 0 及 4, 為各 % 元素相差值 y = sin(x)。 plot(x, y)。 axis([inf, inf, 0, 1])。 % 畫出正弦波 y 軸介於 0 和 1 的部份 MATLAB 程式設計入門篇:二維平面繪圖 圖軸控制範例 1 (II) inf指令: 以資料點 (上例: x 軸的資料點 )的最小和最大值取代之 0 2 4 6 8 10 1201MATLAB 程式設計入門篇:二維平面繪圖 圖軸控制範例 2 (I) 指定圖軸上的格線點 (Ticks) 範例 311: x = 0::4*pi。 plot(x, sin(x)+sin(3*x)) set(gca, ‘ytick’, [1 1])。 % 在 y 軸加上格線點 grid on % 加上格線 MATLAB 程式設計入門篇:二維平面繪圖 圖軸控制範例 2 (II) grid on:加上格線 gca: get current axis的簡稱 傳回目前使用中的圖軸 gca屬 Handle Graphics的指令,第七章會有更詳細的說明 0 2 4 6 8 10 12 1411使用者加入的格線點和文字 MATLAB 程式設計入門篇:二維平面繪圖 圖軸控制範例 3 (I) 將格線點的數字改為文字 範例 312: x = 0::4*pi。 plot(x, sin(x)+sin(3*x)) set(gca, 39。 ytick39。 , [1 1])。 % 改變格線點 set(gca, ‘yticklabel’, {‘極小’ ,‘臨界值’ ,‘崩潰值’ ,‘極大’ })。 % 改變格線點的文字 grid on % 加上格線 MATLAB 程式設計入門篇:二維平面繪圖 圖軸控制範例 3 (II) MATLAB 程式設計入門篇:二維平面繪圖 Subplot subplot 在一個視窗產生多個圖形 (圖軸 ) 一般形式為 subplot (m, n, p) 將視窗分為 m n 個區域 下一個 plot 指令繪圖於第 p 個區域 p 的算法為由左至右,一列一列 MATLAB 程式設計入門篇:二維平面繪圖 圖軸控制範例 4 (I) 同時畫出四個圖於一個視窗中 範例 313: x = 0::4*pi。 subplot(2, 2, 1)。 plot(x, sin(x))。 % 此為左上角圖形 subplot(2, 2, 2)。 plot(x, cos(x))。 % 此為右上角圖形 subplot(2, 2, 3)。 plot(x, sin(x).*exp(x/5))。 % 此為左下角圖形 subplot(2, 2, 4)。 plot(x, x.^2)。 % 此為右下角圖形 MATLAB 程式設計入門篇:二維平面繪圖 圖軸控制範例 4 (II) 0 5 10 151010 5 10 151010 5 10 15010 5 10 15050100150200Subplot(2,2,1) Subplot(2,2,3) Subplot(2,2,2) Subplot(2,2,4) MATLAB 程式設計入門篇:二維平面繪圖 圖軸控制範例 5 (I) 長寬比 (Aspect Ratio) 一般圖軸長寬比是視窗的長寬比 可在 axis 指令後加不同的字串來修改 範例 314: t = 0::2*pi。 x = 3*cos(t)。 y = sin(t)。 subplot(2, 2, 1)。 plot(x, y)。 axis normal subplot(2, 2, 2)。 plot(x, y)。 axis square subplot(2, 2, 3)。 plot(x, y)。 axis equal subplot(2, 2, 4)。 plot(x, y)。 axis equal tight MATLAB 程式設計入門篇:二維平面繪圖 圖軸控制範例 5 (II) 4 2 0 2 41015 0 51012 1 0 1 2 3210122 1 0 1 2 30axis normal axis equal axis square axis square tight MATLAB 程式設計入門篇:二維平面繪圖 改變圖軸長寬比的指令 改變目前圖軸長寬比的指令 需在 plot 指令之後呼叫才能發揮效用 指令 說明 axis normal 使用預設長寬比 (等於圖形長寬比 ) axis square 長寬比例為 1 axis equal 長寬比例不變,但兩軸刻度。matlab程式设计入门篇二维平面绘图
相关推荐
tep 執行下一列程式碼 dbstep n 執行下 n 列程式碼 dbstep in 進入下一列指令的程式碼 dbstep out 跳出目前指令的程式碼 MATLAB 程式設計入門篇:動畫製作 dbclear及 dbstatus 的用法 dbclear 用於取消中斷點,用法與 dbstop的格式同,只需將 dbstop改成 dbclear。 若要清除所有的中斷點,可用 dbclear all
1 16 I initial 3 interpolation 4 bisection 5 interpolation 6 bisection 7 interpolation 8 interpolation 9 interpolation 10 interpolation 11 interpolation 12 interpolation 13 interpolation Zero found
lynom(p)。 q = polynom(q)。 k = length() length()。 r = polynom([zeros(1,k) ] [zeros(1,k) ])。 MATLAB 程式設計進階篇: 物件導向程式設計 有了這兩個函式之後,我們就可以來測詴多項式的加減法,如下: 範例 157: 152 運算元的重載 p = polynom([3 4 2 1])。 q =
一點。 之後再執行 ,就會直接取用速度就會變快了。 提示 MATLAB 程式設計入門篇:通用運算式 使用 mcc 時,還有幾點要注意: 如果你的 MATLAB 函式有呼叫任何你自己定義的函式,要一併放進來編譯。 如果只是要產生 C程式碼,而不產生可執行檔,可以使用「 mcc – mc 」 ( c 代表只產生 C 語言的包裝程式檔案)。 如果要檢視
0)〕 LT 、 L20:分别代表 T℃ 和 20℃ 总的 BOD. the index of marine oxygendemanded pollution The quality standard of seawater (GB 30971997) 项目 第一类水 第二类水 第三类水 第四类水B O D5( mg /l)≦ 1 ≦ 3 ≦ 4 ≦ 5CO D( mg /l)≦ 2 ≦ 3 ≦
drivers respect the rules. C. The road going south from the capital is dangerous. D. It runs north from the capital , La Paz. Parts 23 has the death toll fallen ? 2. What happened to him when he was