matlab complex numbers

26
1 Complex Numbers in MATLAB Lecture Series -2 by Shameer K oya

Upload: ameen-san

Post on 16-Jul-2015

142 views

Category:

Engineering


9 download

TRANSCRIPT

Page 1: Matlab complex numbers

11

Complex Numbers in MATLAB

Lecture Series - 2

by

Shameer Koya

Page 2: Matlab complex numbers

2

Complex Plane

Real Axis x

y

Imaginary Axis

Page 3: Matlab complex numbers

3

Form of Complex Number

Real Axis

Imaginary Axis

( , )x y

z

rx iy z

Page 4: Matlab complex numbers

4

Conversion Between Forms

cosx r

siny r

Polar to Rectangular:

Rectangular to Polar:

2 2r x y

1ang( ) tany

x z

Page 5: Matlab complex numbers

5

Euler’s Formula

cos sin (cos sin )r ir r i z

ire z

ire r

Common Engineering Notation:

cos sinie i

Page 6: Matlab complex numbers

6Convert the complex number to polar form:

4 3i z

2 2 2 2(4) (3) 5r x y

1 3tan 36.87 0.6435 rad

4

5 36.87 or z

0.64355 iez

Page 7: Matlab complex numbers

7Convert the complex number to polar form:

4 3i z

2 2 2 2( 4) (3) 5r x y

1 13 3tan 180 tan

4 4

180 36.87 143.13 2.498 rad

2.4985 iez

Page 8: Matlab complex numbers

8

Convert the complex number to rectangular form:

24 iez

4cos2 1.6646x

4sin 2 3.6372y

1.6646 3.6372i z

Page 9: Matlab complex numbers

9Addition of Two Complex Numbers

1 1x iy 1z

2 2x iy 2z

1 1 2 2

1 2 1 2( )

x iy x iy

x x i y y

sum 1 2z z + z

A geometric interpretation of addition is

shown on the next slide.

Page 10: Matlab complex numbers

10

Addition of Two Complex Numbers

Real Axis

Imaginary Axis

1z

2z

2z

sumz

Page 11: Matlab complex numbers

11

Subtraction of Two Complex Numbers

1 1x iy 1z

2 2x iy 2z

A geometric interpretation of subtraction

is shown on the next slide.

1 1 2 2

1 2 1 2

( )

( )

x iy x iy

x x i y y

diff 1 2z z - z

Page 12: Matlab complex numbers

12

Subtraction of Two Complex Numbers

Real Axis

Imaginary Axis

1z

2z

2

z

diffz

2

z

Page 13: Matlab complex numbers

13Multiplication in Polar Form

1

1

ir e

1z

2

2

ir e

2z

1 2

1 2

1 2

( )

1 2

i i

i

re r e

r r e

prod 1 2z = z z

Page 14: Matlab complex numbers

14Division in Polar Form1

1

ir e

1z

2

2

ir e

2z

1

2

1 2

1

2

( )1

2

i

i

i

re

r e

re

r

1div

2

zz =

z

Page 15: Matlab complex numbers

15Multiplication in Rectangular Form

1 1x iy 1z

2 2x iy 2z

1 1 2 2

2

1 2 1 2 2 1 1 2

( )( )x iy x iy

x x ix y ix y i y y

prodz

1 2 1 2 1 2 2 1( )x x y y i x y x y prodz

Page 16: Matlab complex numbers

16

Complex Conjugate

Start with

ix iy re z

The complex conjugate is

ix iy re z

2 2 2

The product of and is

( )( )

z z

x y r z z

Page 17: Matlab complex numbers

17

Division in Rectangular Form

1 1

2 2

x iy

x iy

1div

2

zz

z

1 1 2 2

2 2 2 2

1 2 1 2 2 1 1 2

2 2

2 2

1 2 1 2 2 1 1 2

2

( )( )

( )( )

( )

( )

x iy x iy

x iy x iy

x x y y i x y x y

x y

x x y y i x y x y

r

divz

Page 18: Matlab complex numbers

18

Exponentiation of Complex Numbers: Integer Power

N

powerz = (z)

( )

cos sin

i N N iN

N N

re r e

r N ir N

powerz

cos Re( )iNN e

sin Im( )iNN e

Page 19: Matlab complex numbers

MATLAB Complex Operations

Complex number

Construct complex data from real and imaginary components

>> c = complex(a,b)

>> z = 3 + 4iz =

3.0000 + 4.0000i>> z = 3 + 4jz =

3.0000 + 4.0000i

19

Page 20: Matlab complex numbers

20

MATLAB Complex Number Operations: Entering in Polar Form

>> z = 5*exp(0.9273i)

z =

3.0000 + 4.0000i

>> z = 5*exp((pi/180)*53.13i)

z =

3.0000 + 4.0000i

This result indicates that polar to rectangular conversion occurs automatically upon entering the number in polar form.

Page 21: Matlab complex numbers

21

Rectangular to Polar Conversion

>> z = 3 + 4i

z =

3.0000 + 4.0000i

>> r = abs(z)

r =

5

>> theta = angle(z)

theta =

0.9273

Page 22: Matlab complex numbers

22

Real and Imaginary and Conjugate

>>real(z)

ans =

3

>> imag(z)

ans =

4

>> z1 = conj(z)

z1 =

3.0000 - 4.0000i

Page 23: Matlab complex numbers

Complex Algebra

Z1 = 3+4i

Z2 = 2-5i

Z3 = Z1+Z2

Z4 = Z1-Z2

Z5 = Z1*Z2

Z6 = Z1/Z2

23

Page 24: Matlab complex numbers

Plotting complex number

Use simple ‘plot’ function

Plot (real, imaginary)

Use ‘compass’ function

Compass (z)

24

Page 25: Matlab complex numbers

Exercise

a= 3+2i b= 4+5i

Find

Magnitude of a

Angle of a

Real part of a

Imaginary part of a

Conjugate of a

Plot a and b using ‘plot’ and ‘compass’

a+b, a-b, a/b, a*b, a2

25

Page 26: Matlab complex numbers

26

Thanks

Questions ??