Presentation is loading. Please wait.

Presentation is loading. Please wait.

Digital Signal Processing with Examples in M ATLAB ® Chap 1 Introduction Ming-Hong Shih, Aug 25, 2003.

Similar presentations


Presentation on theme: "Digital Signal Processing with Examples in M ATLAB ® Chap 1 Introduction Ming-Hong Shih, Aug 25, 2003."— Presentation transcript:

1 Digital Signal Processing with Examples in M ATLAB ® Chap 1 Introduction Ming-Hong Shih, Aug 25, 2003

2 Ming-Hong ShihDigital Signal Processing with Example in MATLAB 2 Introduction to M ATLAB Why is M ATLAB in use by a large fraction of the DSP community? (1)The user do most DSP operations with very simple lines of code. (2)MATLAB’s graphics support. (3)Don’t to be an expert in MATLAB.

3 Ming-Hong ShihDigital Signal Processing with Example in MATLAB 3 Variables, Vectors, Matrices, and Arrays 1. Variable: 一個單獨的元素 ( 整數、實數、複數 ) 。 2. 向量 (Vector): 一維的矩陣,可分為 Column Vectors 及 Row Vectors 。 3. 矩陣 (Matrices): 二維的陣列,一維向量為其特例。 4. 陣列 (Arrays): Using array as an inclusive term to designate a vector or a matrix.

4 Ming-Hong ShihDigital Signal Processing with Example in MATLAB 4 Variables, Vectors, Matrices, and Arrays ──→ Variable ──→ Vector ──→ Matrix

5 Ming-Hong ShihDigital Signal Processing with Example in MATLAB 5 Indexing a matrix  A=[1 2; 3 4];  A(1,1)=1; % the index starts from 1  A(1,2)=2;  A(2,1)=3;  A(2,2)=4;

6 Ming-Hong ShihDigital Signal Processing with Example in MATLAB 6 Array Operation - Sum(+) and Difference(-) The sum or difference of two array is obtained simply by adding or subtracting the individual element.

7 Ming-Hong ShihDigital Signal Processing with Example in MATLAB 7 Array Operation - Sum(+) and Difference(-) (cont.) Dimensions must be the same unless one variable is a scalar. 矩陣與純量可以直接進行加減, M ATLAB 會直接將加減應用到 每一個元素。

8 Ming-Hong ShihDigital Signal Processing with Example in MATLAB 8 Array Operation - Product(*) 純量對矩陣的乘或除, 可比照一般寫法。 矩陣與純量可以直接進行乘法, MATLAB 會直接將乘法應用到 每一個元素。

9 Ming-Hong ShihDigital Signal Processing with Example in MATLAB 9 Array Operation - Product(*) (cont.) 進行矩陣相乘,必需確認第一個矩陣的 直行數目 (Column Dimension) 必需等於 第二個矩陣的橫列數目 (Row Dimension) ,否則其乘法無從定義, MATLAB 會產 生錯誤訊息。

10 Ming-Hong ShihDigital Signal Processing with Example in MATLAB 10 Array Operation - Exponentiation(^) 矩陣的次方運算,可由「 ^ 」 來達成,但矩陣必需是方矩陣 ,其次方運算才有意義。

11 Ming-Hong ShihDigital Signal Processing with Example in MATLAB 11 Array Operation - Product(.*) and Exponentiation(.^) 若在「 * 」及「 ^ 」之前加上 一個句點, MATLAB 將會 執行矩陣內「元素對元素」 (Element-by-element) 的運算

12 Ming-Hong ShihDigital Signal Processing with Example in MATLAB 12 Array Operation - Transpose( ′ and. ′ ) 若處理的是 實數,那麼 ‘ 和.‘ 後的 結果是一樣 的。

13 Ming-Hong ShihDigital Signal Processing with Example in MATLAB 13 Array Operation - Transpose( ′ and. ′ ) (cont.) 若處理的是複數, 那麼 ′ 和. ′ 後的結 果是不一樣的。所 以,若不希望 conjugation 出現, 就要用. ′ 。

14 Ming-Hong ShihDigital Signal Processing with Example in MATLAB 14 Example – M-file % ex1.m A=[1 2 3 4 2; 3 4 2 1 2; 4 2 1 2 3; 1 2 3 4 2]; map=[0 0 0; 85/255 85/255 85/255; 170/255 170/255 170/255; 1 1 1]; image(A); colormap(map); colorbar;

15 Ming-Hong ShihDigital Signal Processing with Example in MATLAB 15 Example – M-file(cont.)

16 Ming-Hong ShihDigital Signal Processing with Example in MATLAB 16 Matlab functions  Matlab has lot of toolboxes, which contain many functions  help function-name  On-line help for a function  lookfor keyword  Search for functions that are related to this keyword

17 Ming-Hong ShihDigital Signal Processing with Example in MATLAB 17 Loop Example: for i=1:1:10 a(i) = i; end;

18 Ming-Hong ShihDigital Signal Processing with Example in MATLAB 18 Laboratory exercise #1  Read and show an image: > I=double(imread(‘swim.bmp’)); > imshow(I, []); Perform the following operation to matrix I: 1234 2234 3432 1324 1234 2 2.55 3 1


Download ppt "Digital Signal Processing with Examples in M ATLAB ® Chap 1 Introduction Ming-Hong Shih, Aug 25, 2003."

Similar presentations


Ads by Google