Presentation is loading. Please wait.

Presentation is loading. Please wait.

Communication Engineering National Central University Video-Audio Processing Laboratory Matlab 簡介 指導教授:張寶基 研究生:鄭玉欣、黃振原 音視訊處理實驗室 2006 / 10 / 3.

Similar presentations


Presentation on theme: "Communication Engineering National Central University Video-Audio Processing Laboratory Matlab 簡介 指導教授:張寶基 研究生:鄭玉欣、黃振原 音視訊處理實驗室 2006 / 10 / 3."— Presentation transcript:

1 Communication Engineering National Central University Video-Audio Processing Laboratory Matlab 簡介 指導教授:張寶基 研究生:鄭玉欣、黃振原 音視訊處理實驗室 2006 / 10 / 3

2 Communication Engineering National Central University Video-Audio Processing Laboratory 2 大綱  什麼是 Matlab ?  Matlab 常見符號  基本矩陣表示法  矩陣的基本運算  程式流程控制  M 檔案與 M 函數  常用指令  影像的讀取與寫入

3 Communication Engineering National Central University Video-Audio Processing Laboratory 3 什麼是 Matlab?  MATrix LABoratory  History  1978, 新墨西哥大學 Pf. Cleve Moler 原創, using Fortran  Stanford 的 Jack Little 將 Matlab 以 C 語言改寫  於 1984 年首次由 MathWorks 推出商用版  目前最新版本為 2006a 版  Property  矩陣之運算分析、二維及三維圖形繪製  Toolbox: image processing, Wavelet, etc.

4 Communication Engineering National Central University Video-Audio Processing Laboratory 4 常用輔助指令  常用輔助指令  help 查看副函式用法  lookfor 查詢相關副函式  who, whos 查看變數  what 查看現在目錄  load, save 資料存取  clc 清除螢幕  clear 清除所有變數  clf 清除 figure  常用技巧  ctrl + c 可中斷程式執行

5 Communication Engineering National Central University Video-Audio Processing Laboratory 5  常見符號  i 、 j 表示虛數 ( )  NaN 非數字符號 ( Not a Number)  Inf 無限大的數  eps Matlab 浮點數的精確度  pi 圓周率  輔助符號  % 註解符號  pause 暫停程式  ; 表示敘述的結束,但不會顯示執行結果 – 不打分號 (;) 會如何 ? – 換行時怎麼辦 ? Matlab 常見符號 demo1

6 Communication Engineering National Central University Video-Audio Processing Laboratory 6  變數不需宣告即可直接使用  英文字母的大小寫是有分別的  用中括號 [ ] 表示矩陣開始與結束  用逗號 (,) 或空白鍵區別矩陣中的元素  向量表示法 x = 起始值 : 增加值 : 結束值 ( 若無指定增加值,則預設增加值為 1 )  取出矩陣中的單一元素: x(n,m) n : row m : column 基本矩陣表示法 demo2

7 Communication Engineering National Central University Video-Audio Processing Laboratory 7  矩陣的合併與分割  a = [b1 ; b2]; c = [b1 b2];  a = a(1:3, 4:5);  矩陣的轉置  a = a’ → Q : 如何做共軛轉置 ( ) ?  矩陣的加減  c = a + b;  d = a - b; 矩陣的基本運算 (1/2) demo3

8 Communication Engineering National Central University Video-Audio Processing Laboratory 8 矩陣的基本運算 (2/2)  矩陣的乘除及次方  c = a * b;  d = a / b;  ( a * b -1 )  e = a \ b;  ( a -1 * b )  f = a ^ 3;  ( a*a*a )  陣列的乘除及次方  c = a.* b;  d = a./ b;  e = a.\ b;  f = a.^ 3; Note :陣列的運算是 “ 對應位置 ” 的元素做運算,與矩陣運算差異甚大,請小 心分辨使用時機。 demo4

9 Communication Engineering National Central University Video-Audio Processing Laboratory 9 程式流程控制 for n=1:1:10 statement; end while n~=10 statemant; end if condition statement; elseif statement; else statemnet; end (1) (2) (3)

10 Communication Engineering National Central University Video-Audio Processing Laboratory 10 M 檔案與 M 函數  M 檔案 ( 類似批次檔 )  將一群指令輸入至檔案中 (.m 檔 ) ,執行該檔案即可依序執行檔案內的指令  M 函數 ( 可有輸入、輸出參數 )  必需在檔案開頭宣告函數名稱、輸入參數及輸出參數 [output1, output2….] = function(input1, input2….)  呼叫函式時,是以檔名為主,非程式內函告的 function name

11 Communication Engineering National Central University Video-Audio Processing Laboratory 11 常用運算指令  inv() 計算反矩陣  det() 計算行列式值  real(), Imag() 取實部、虛部  abs(), angle() 取絕對值、角度  conj() 取共軛  eig() 計算特徵值及特徵向量  zeros() 產生全為0的矩陣  ones() 產生全為1的矩陣  sin(), cos(), tan(), … log(), exp(), sqrt() 各種數學函數 Demo5

12 Communication Engineering National Central University Video-Audio Processing Laboratory 12 常用繪圖指令  subplot( nmk ) 切割成 n x m 個子圖,並將繪於第 k 個子圖  plot() 描繪標準線性坐標圖  title() 設定標題文字  xlabel() ylabel() 設定 x 、 y 軸文字  figure() 開新圖, 可指定位置及大小 position, [x y wide length]  stem() 描繪離散針狀圖  hist() 描繪統計圖 Demo6

13 Communication Engineering National Central University Video-Audio Processing Laboratory 13 影像檔案的讀取與寫入  imread() 用於讀取影像檔案  imwrite() 用於寫入影像檔案  imfinfo() 用於傳回影像檔案的各項資訊  help MATLAB Functions: Functions - By Category: Images

14 Communication Engineering National Central University Video-Audio Processing Laboratory 14  imread() 用於讀取影像檔案 RGB=imread('C:\Documents and Settings\jyhuang\ 桌面 \Water lilies.jpg'); image(RGB)  imwrite() 用於寫入影像檔案 load clown imwrite(X,map,'clown.jpg'); !start clown.jpg % 呼叫 Windows 作業系統的應用程式來開啟 clown.jpg  imfinfo() 用於傳回影像檔案的各項資訊 imfinfo('clown.jpg')

15 Communication Engineering National Central University Video-Audio Processing Laboratory 15 參考資料  “Matlab 之使用與應用 ” ,林傳生,儒林圖書  “MATLAB 程式設計與應用 ” ,張智星,清蔚科技


Download ppt "Communication Engineering National Central University Video-Audio Processing Laboratory Matlab 簡介 指導教授:張寶基 研究生:鄭玉欣、黃振原 音視訊處理實驗室 2006 / 10 / 3."

Similar presentations


Ads by Google