zen and the art of matlab damian gordon. hard work done by : daphne gilbert & susan lazarus

23
Zen and the Art of MatLab Damian Gordon

Post on 21-Dec-2015

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Zen and the Art of MatLab Damian Gordon. Hard work done by : Daphne Gilbert & Susan Lazarus

Zen and the Art of MatLab

Damian Gordon

Page 2: Zen and the Art of MatLab Damian Gordon. Hard work done by : Daphne Gilbert & Susan Lazarus

Hard work done by :

Daphne Gilbert &

Susan Lazarus

Page 3: Zen and the Art of MatLab Damian Gordon. Hard work done by : Daphne Gilbert & Susan Lazarus

Introduction to MatLab

• MatLab is an interactive, matrix-based system for numeric computation and visualisation

• MATrix LABoratory

• Used in image processing, image synthesis, engineering simulation, etc.

Page 4: Zen and the Art of MatLab Damian Gordon. Hard work done by : Daphne Gilbert & Susan Lazarus

References

• “Mastering MatLab” Duane Hanselman, Bruce Littlefield

• “The MatLab Primer” http://www.fi.uib.no/Fysisk/Teori/KURS/WRK/mat/mat.html

• “The MatLab FAQ” http://www.isr.umd.edu/~austin/ence202.d/matlab-faq.html

Page 5: Zen and the Art of MatLab Damian Gordon. Hard work done by : Daphne Gilbert & Susan Lazarus

Printed Circuit Board

Page 6: Zen and the Art of MatLab Damian Gordon. Hard work done by : Daphne Gilbert & Susan Lazarus

Specific Bond Selected

Page 7: Zen and the Art of MatLab Damian Gordon. Hard work done by : Daphne Gilbert & Susan Lazarus

Bond Shape Estimated

Page 8: Zen and the Art of MatLab Damian Gordon. Hard work done by : Daphne Gilbert & Susan Lazarus

MATLAB Command Window

To get started, type one of these: helpwin, helpdesk, or demo. For product information, type tour or visit www.mathworks.com. »

» help

HELP topics:

Page 9: Zen and the Art of MatLab Damian Gordon. Hard work done by : Daphne Gilbert & Susan Lazarus

Creating Variables

>> varname = 12

varname =

12

>> SS = 56; N = 4; Tot_Num = SS + N

Tot_Num =

60

Page 10: Zen and the Art of MatLab Damian Gordon. Hard work done by : Daphne Gilbert & Susan Lazarus

Operations

+ Addition

- Subtraction

* Multiplication

^ Power

\ Division

/ Division

• Add vars• Subtract vars

Multiplication • Raise to the power• Divide vars (A div B)• Divide vars (B div A)

Page 11: Zen and the Art of MatLab Damian Gordon. Hard work done by : Daphne Gilbert & Susan Lazarus

Creating Complex Numbers

>> 3 + 2i

>> sqrt(9) + sin(0.5)*j

ans =

3.0000 + 0.4794i

Num = sqrt(9) + sin(0.5)*j

real(Num)

imag(Num)

Page 12: Zen and the Art of MatLab Damian Gordon. Hard work done by : Daphne Gilbert & Susan Lazarus

Entering Matrices (1)

>> A = [1 2 3; 4 5 6; 7 8 9]

OR

>> A = [

1 2 3

4 5 6

7 8 9 ]

Page 13: Zen and the Art of MatLab Damian Gordon. Hard work done by : Daphne Gilbert & Susan Lazarus

Entering Matrices (2)

• To create an NxM zero-filled matrix

>> zeros(N,M)• To create a NxN zero-filled matrix

>> zeros(N)• To create an NxM one-filled matrix

>> ones(N,M)• To create a NxN one-filled matrix

>> ones(N)

Page 14: Zen and the Art of MatLab Damian Gordon. Hard work done by : Daphne Gilbert & Susan Lazarus

Entering Matrices (3)

• To create an NxM randomly-filled matrix (which is uniformly distributed)

>> rand(N,M)

• To create an NxM randomly-filled matrix (which is normally distributed)

>> randn(N,M)

Page 15: Zen and the Art of MatLab Damian Gordon. Hard work done by : Daphne Gilbert & Susan Lazarus

Complex Matrices

• To enter a complex matrix, you may do it in one of two ways :

>> A = [1 2; 3 4] + i*[5 6;7 8]

OR

>> A = [1+5i 2+6i; 3+7i 4+8i]

Page 16: Zen and the Art of MatLab Damian Gordon. Hard work done by : Daphne Gilbert & Susan Lazarus

MATLAB Command Window

» who

Your variables are:

a b c

» whos Name Size Bytes Class

a 8x8 512 double array b 9x9 648 double array c 9x9 648 double array

Grand total is 226 elements using 1808 bytes

Page 17: Zen and the Art of MatLab Damian Gordon. Hard work done by : Daphne Gilbert & Susan Lazarus

Matrix Addition» A = [ 1 1 1 ; 2 2 2 ; 3 3 3]

» B = [3 3 3 ; 4 4 4 ; 5 5 5 ]

» A + B

ans =

4 4 4

6 6 6

8 8 8

Page 18: Zen and the Art of MatLab Damian Gordon. Hard work done by : Daphne Gilbert & Susan Lazarus

Matrix Subtraction» A = [ 1 1 1 ; 2 2 2 ; 3 3 3]

» B = [3 3 3 ; 4 4 4 ; 5 5 5 ]

» B - A

ans =

2 2 2

2 2 2

2 2 2

Page 19: Zen and the Art of MatLab Damian Gordon. Hard work done by : Daphne Gilbert & Susan Lazarus

Matrix Multiplication» A = [ 1 1 1 ; 2 2 2 ; 3 3 3]

» B = [3 3 3 ; 4 4 4 ; 5 5 5 ]

» A * B

ans =

12 12 12

24 24 24

36 36 36

Page 20: Zen and the Art of MatLab Damian Gordon. Hard work done by : Daphne Gilbert & Susan Lazarus

Matrix - Power» A ^ 2

ans =

6 6 6

12 12 12

18 18 18

» A ^ 3

ans =

36 36 36

72 72 72

108 108 108

Page 21: Zen and the Art of MatLab Damian Gordon. Hard work done by : Daphne Gilbert & Susan Lazarus

Matrix Transpose

A =

1 1 1

2 2 2

3 3 3

» A'

ans =

1 2 3

1 2 3

1 2 3

Page 22: Zen and the Art of MatLab Damian Gordon. Hard work done by : Daphne Gilbert & Susan Lazarus

Matrix Division

Left Division \

x = A\B (is A*x=B)

>> A = rand(4)

>> B = rand(4)

>> C = A \ B

=> A * C = B

Right Division /

x=A/B (is x*A=B)

>> A = rand(4)

>> B = rand(4)

>> C = A / B

=> C * A = B

Page 23: Zen and the Art of MatLab Damian Gordon. Hard work done by : Daphne Gilbert & Susan Lazarus

Matrix Operations

+ Addition

- Subtraction

* Multiplication

^ Power

‘ Conjugate Transpose

\ Left Division

/ Right Division

• Add matrices• Subtract matrices

Matrix Multiplication • Raise to the power• Get transpose• x = A\B (is A*x=B)• x=A/B (is x*A=B)