S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Matlab Basics...

7
S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan- Dearborn Matlab Basics Introduction to Matlab: Matrix Operations

Transcript of S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Matlab Basics...

Page 1: S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Matlab Basics Introduction to Matlab: Matrix Operations.

S. Awad, Ph.D.

M. Corless, M.S.E.E.

E.C.E. Department

University of Michigan-Dearborn

MatlabBasics

Introduction to Matlab:

Matrix Operations

Page 2: S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Matlab Basics Introduction to Matlab: Matrix Operations.

2

MATLAB Basics:» U of M-Dearborn ECE DepartmentIntroduction to MATLAB and its Toolboxes

Matrix Operations

Matrix Operations Transpose Addition Subtraction Multiplication Matrix Powers

Page 3: S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Matlab Basics Introduction to Matlab: Matrix Operations.

3

MATLAB Basics:» U of M-Dearborn ECE DepartmentIntroduction to MATLAB and its Toolboxes

Matrix Operations

Transpose of a Matrix

» a = [ 1 2 3; 4 5 6; 7 8 9];

987

654

321

a

963

852

741

b

» b = a’;

Page 4: S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Matlab Basics Introduction to Matlab: Matrix Operations.

4

MATLAB Basics:» U of M-Dearborn ECE DepartmentIntroduction to MATLAB and its Toolboxes

Matrix Operations

Matrices a, b, & c will have same dimensions For addition c(i,j) = a(i,j) + b(i,j)

Note: c = a + 1 means c(i,j) = a(i,j) + 1

Addition of Matrices

» c = a + b

987

654

321

a

963

852

741

b

c =

2 6 10

6 10 14

10 14 18

Page 5: S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Matlab Basics Introduction to Matlab: Matrix Operations.

5

MATLAB Basics:» U of M-Dearborn ECE DepartmentIntroduction to MATLAB and its Toolboxes

Matrix Operations

Subtraction of Matrices Matrices a, b, & d will have same dimensions For subtraction d(i,j) = a(i,j) - b(i,j)

» d = a - b

d =

0 -2 -4

2 0 -2

4 2 0

Note: d = a - 1 means d(i,j) = a(i,j) - 1

987

654

321

a

963

852

741

b

Page 6: S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Matlab Basics Introduction to Matlab: Matrix Operations.

6

MATLAB Basics:» U of M-Dearborn ECE DepartmentIntroduction to MATLAB and its Toolboxes

Matrix Operations

m

k

jkbkiajic1

),(),(),(

Multiplication of Matrices Suppose: a is n x m (n by m) & b is m x for c = a * b, c must be n x

» a = [ 1 1 1];

» c = a * a’; % c = 1 + 1 + 1

c =

3

Page 7: S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Matlab Basics Introduction to Matlab: Matrix Operations.

7

MATLAB Basics:» U of M-Dearborn ECE DepartmentIntroduction to MATLAB and its Toolboxes

Matrix Operations

Assume that a is a square matrix, then b = a^2 means b = a* a c = a^5 means a*a*a*a*a

In general d = a^p = a*a*a*...*a (for p times)

In case p is not an integer (i.e. p = 1/2) e = a^0.5 means a = e*e

Note: a^-1 inv(a)

Matrix Powers