Download presentation
Presentation is loading. Please wait.
1
Communication Engineering National Central University Video-Audio Processing Laboratory Matlab 簡介 指導教授:張寶基 研究生:梁凱雯 陳宗毅 音視訊處理實驗室 2007 / 9 / 27
2
Communication Engineering National Central University Video-Audio Processing Laboratory 大綱 u 什麼是 Matlab ? u Matlab 常見符號 u 基本矩陣表示法 u 矩陣的基本運算 u 程式流程控制 u M 檔案與 M 函數 u 常用指令
3
Communication Engineering National Central University Video-Audio Processing Laboratory 什麼是 Matlab? u MATrix LABoratory u History 1978, 新墨西哥大學 Pf. Cleve Moler 原創, using Fortran Stanford 的 Jack Little 將 Matlab 以 C 語言改寫 於 1984 年首次由 MathWorks 推出商用版 目前最新版本為 7.0 版 u Property 以矩陣運算為主 Toolbox: image processing, Wavelet, etc. Simulink
4
Communication Engineering National Central University Video-Audio Processing Laboratory Matlab 常見符號 u 常見符號 i 、 j 表示虛數 (√-1) NaN 沒有意義的數 Inf 無限大的數 eps Matlab 浮點數的精確度 pi 圓周率 分號 ( ; ) 表示敘述的結束,但不會顯示執行結果
5
Communication Engineering National Central University Video-Audio Processing Laboratory 基本矩陣表示法 u Matlab 的變數不需宣告即可直接使用 u Matlab 中,英文字母的大小寫是有分別的 u 用中括號 [ ] 表示矩陣開始與結束 u 用逗號 (,) 或空白鍵區別矩陣中的元素 u 用分號 (;) 或是換行鍵 (Enter) 來區別每列的結束 u 向量表示法 x= 起始值 : 增加值 : 結束值 ( 若無指定增加值,則預設增加值為 1) u 取出矩陣中的單一元素: x(n,m)
6
Communication Engineering National Central University Video-Audio Processing Laboratory 矩陣的基本運算 (1/2) u 矩陣的合併與分割 : a = [b; r]; c = [b r]; a = a(1:3, 4:5); u 矩陣的 Hermitian ( 共軛轉置 ): a = a’ u 矩陣的加減 c = a + b; d = a - b;
7
Communication Engineering National Central University Video-Audio Processing Laboratory 矩陣的基本運算 (2/2) u 矩陣的乘除及次方 c = a * b; d = a / b; ( a * b -1 ) e = a \ b; ( a -1 * b ) f = a ^ 3; u 陣列的乘除及次方 c = a.* b; d = a./ b; e = a.\ b; f = a.^ 3; u 宜注意,陣列的運算是 “ 對應位置 ” 的元素做運算,與矩陣運算差異甚 大,請小心分辨使用時機。
8
Communication Engineering National Central University Video-Audio Processing Laboratory 程式流程控制 for n=1:1:10 statement; end while n~=10 statemant; end if condition statement; elseif statement; else statemnet; end
9
Communication Engineering National Central University Video-Audio Processing Laboratory M 檔案與 M 函數 u M 檔案 ( 類似批次檔 ) 將一群指令輸入至檔案中 (.m 檔 ) ,執行該檔案即可依序執行 檔案內的指令 u M 函數 ( 可有輸入、輸出參數 ) 必需在檔案開頭宣告函數名稱、輸入參數及輸出參數 [output1,output2….]=function(input1,input2….) u 輔助符號及函數 % 註解符號 pause 暫停程式
10
Communication Engineering National Central University Video-Audio Processing Laboratory 常用輔助指令 u 常用輔助指令 help 查看副函式用法 lookfor 查詢相關副函式 who,whos 察看變數 what 察看現在目錄 load, save 資料存取 clc 清除螢幕 clear 清除所有變數 u 常用技巧 Ctrl + C 可中斷程式執行
11
Communication Engineering National Central University Video-Audio Processing Laboratory 常用運算指令 u inv() 計算反矩陣 u det() 計算行列式值 u real(), Imag() 取實部、虛部 u abs(), Angle() 取絕對值、角度 u conj() 取共軛 u eig() 計算特徵值及特徵向量 u zeros() 產生全為0的矩陣 u ones() 產生全為1的矩陣 u sin(), cos(), tan(), … log(), exp(), sqrt() 各種數學函數
12
Communication Engineering National Central University Video-Audio Processing Laboratory 常用繪圖指令 u subplot( nmk ) 切割成 n x m 個子圖,並將繪於第 k 個子圖 u plot() 描繪標準線性坐標圖 title() 設定標題文字 xlabel() ylabel() 設定 x 、 y 軸文字 figure() 開新圖 u stem() 描繪離散針狀圖 u hist() 描繪統計圖
13
Communication Engineering National Central University Video-Audio Processing Laboratory 參考資料 u “Matlab 之使用與應用 ” ,林傳生,儒林圖書 u “MATLAB 程式設計與應用 ” ,張智星,清蔚科技
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.