Professional Documents
Culture Documents
Experiment 1
MATLAB and Complex Numbers
Objectives
By the end of the experiment, the student should be able to
define the different MATLAB windows and tools.
find the difference between a constant, variable and expression.
demonstrate the different mathematical operations of complex numbers.
construct a script file for computing complex number.
Tools Required
Personal Computer/Desktop Computer/Computer Workstation
MATLAB software
I. COMPLEX NUMBERS
Ex. j5 , j6 , j8
where: j = -1 j3 = - j
j2 = -1 j4 = 1
COMPLEX NUMBER - is the sum of the difference of a real number and an imaginary
number.
Ex. 5 + j2 , 6 - j8
Graphical Representation of Complex Numbers
Imaginary Axis 4
•
3
-4 -3 -2 -1 1 2 3 4
-1
Real Axis
•
-2
b (a, b)
cos θ = a / r ; sin θ = b / r
a = r cos θ ; b = r sin θ
tan θ = y/ x
|z| = r = √( a2 + b2)
FORMS OF COMPLEX NUMBERS
( x , y ) Rectangular Form
Polar Form
Z = r 0
where:
r = magnitude
= distance of the pt. (a,b) from the
origin
= modulus of the complex no. Z
( always a non-negative number
and is denoted |z| )
= angle with respect to the positive x
axis in degrees.
= argument of Z denoted as arg (z)
Note: is positive when measured counter clockwise and negative when measured
clockwise with respect to the positive x axis.
Z = r cos θ + j r sin θ
= r ( cos θ + j sin θ )
Z=rθ
Note that
r - θ = r ( cos(-θ) + j sin (-θ))
= r (cos - j sin θ)
= z (bar)
Thus,
If z = a + jb then z = a – jb and
z = r ( - θ)
Trigonometric Form
Z = r ( cos + j sin )
Z = r cos + j r sin θ
Exponential Form
Z = r e j
where:
r = magnitude
= angle in radians
Note:
in degrees = / 1800
Euler’s Equation
A cos + j A sin = A e j
Coordinate Conversion
Z = a + jb r
where:
r = a 2 + b2
= tan -1 ( b/a )
Z = r a + jb
Where:
x = r cos
y = r sin
Complex Conjugate
change the sign of the imaginary part.
Ex.
-7 + j = -7 – j
6 + j5 = 6 – j5
6 = there is no imaginary part to alter
j = -j
Operations of Complex numbers
Addition / Subtraction
A. Rectangular Form
A = x + jy ; B = a + jb
A + B = (x + a) + j (y + b)
B. Polar Form
X = A 1 ; Y = B 2
X = A cos 1 + j A sin 1
Y = B cos 2 + j B sin 2
II. Multiplication
Rectangular Form
A = x + jy ; B = a + jb
A x B = (x + jy) x (a + jb)
A x B = ax + jbx + jay + j2 by
A x B = ( ax - by ) + j( ay + bx )
Polar Form
X = A 1 ; Y = B 2
X Y = A B ( 1 + 2 )
III. Division
Rectangular Form
A = x + jy ; B = a + jb
A = x + jy a - jb
B a + jb a - jb
A = ax + jay - jbx - j2 by
B a2 - j2 b2
A = ( ax + by ) + j ( ay - bx )
B a 2 + b2
A = ( ax + by ) + j ( ay - bx )
B a2 + b2 a2 + b2
Polar Form
X = A 1 ; Y = B 2
X = A 1 = A 1- 2
Y B 2 B
Real Powers
( A )n = An n
= ( A e j / 180 ) n
= ( An e j / 180 n )
= ( An /180 n 180/ )
= An n
Real Roots
n ( A ) = n A ( /n )
= ( A e j / 180 ) 1/n
= ( A 1/n e j / 180 1/n )
= ( A 1/n /180 1/n 180/ )
= n A ( /n )
Complex Powers
( A ) x + jy = R
= ( A e j / 180 ) x + jy
= ( e lnA e j / 180 ) x + jy
= ( e lnA + j / 180 ) x + jy
= ( e xlnA + jx / 180 + jylnA + j2 y / 180 )
= ( e ( xlnA - y / 180 ) + j ( ylnA + x / 180 ) )
= ( e ( xlnA - y / 180 ) e j ( ylnA + x / 180 ) )
= R e j
R = e ( xlnA - y / 180 )
= ( ylnA + x / 180 ) 180 /
Complex Roots
( A ) = S
x + jy
= (A e j / 180) 1 / ( x + jy )
= (e lnA e j / 180) 1 / ( x + jy )
= (e lnA + j / 180) 1 / ( x + jy )
= (e ( lnA + j / 180 ) / ( x + jy )) ( x - jy / x - jy )
= (e{( xlnA + j x / 180 )-( jy lnA+ j2 y /180)}/{ x2- j2y2 })
= (e(xlnA - y / 180)/(x2 + y2) e j (- ylnA + x /180)/(x2+y2))
= S e j
S = e { (xlnA + y / 180) / (x2 + y2) }
= {(- ylnA + x / 180)/(x2+y2)} 180/
Log ( A )
= Log ( A e j / 180 )
= Log A + Log e j / 180
= Log A + j / 180 Log e
= Log A + j / 180 0.4343
Ln ( A )
= Ln ( A e j / 180 )
= Ln A + Ln e j / 180
= Ln A + j / 180 Ln e
= Ln A + j / 180 1
Log ( - N )
= Log ( N 180 )
= Log N + j 180 / 180 Log e
= Log N + j 0.4343
Ln ( - N )
= Ln ( N 180 )
= Ln N + j 180 / 180 Ln e
= Ln N + j 1
complex number
>>sqrt(-1)
Polynomial Roots
x^2 + 1 = 0
>> p = [1 0 1]
>> roots (p)
3 + 4i
>> c = 3 + 4*i
or
>> c = 3 + 4*j
or
>> c = complex(3,4)
Compass plot.
compass(U,V) draws a graph that displays the vectors with
components (U,V) as arrows emanating from the origin.
Example
>> c = complex(3,4)
>> compass (c)
Live Script
MATLAB live scripts and live functions are interactive documents that combine
MATLAB code with embedded output, formatted text, equations, and images in a single
environment called the Live Editor.
Show that Im[jz] = Re[z] and Re[-jz] = Im[z]. Run the following MATLAB program in
order to compute and plot the complex number e^(j*theta) for theta = i*2*pi/360, i = 1,
2,...,360:
j=sqrt(-1)
n=360
for i=1:n,circle(i)=exp(j*2*pi*i/n);end;
axis('square')
plot(circle)
circle=exp(j*2*pi*[1:n]);
to speed up the calculation. You can see from the figure below that the complex number
e^(j*theta), evaluated at angles theta = 2*pi/360, 2(2*pi/360),..., turns out complex
numbers that lie at angle theta and radius 1. We say that e^(j*theta) is a complex
number that lies on the unit circle.
The Complex Numbers e^(j*theta) for 0<theta<2*
m-file
Create and run the following script file (name it ComplexNum)
function complexnumbers
j=sqrt(-1);
z1=(1+(j*.5));z2=(2+(j*1.5));
z3=z1+z2;z4=(z1*z2);
z5=conj(z1);z6=(j*z2);
axis([-4 4 -4 4]),axis('square'),plot(z1,'o')
hold on
grid on
plot(z2,'o'),plot(z3,'+'),plot(z4,'*'),
plot(z5,'x'),plot(z6,'x')
Complex Numbers
Exercises:
Syntax:________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
b. (arccot(-jπ/6))/(sinh(0.5+j0.75)
Answer:_______________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
Syntax:________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
√−1
c. ln6 + log(-7) – ln(7+j5)(2+j3) +√−1 + loge(8+j3)
Answer:_______________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
Syntax:________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
(4+𝑗3)+7∠40 6𝑐𝑗𝑠30+9∠−40
d. √ +√ − √(6 + 𝑗3)(4∠40)(7 − 𝑗3)
(3−𝑗8)2 6∠30+𝑗9
Answer:_______________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
Syntax:________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
e. the fourth roots of [(2+Ln(i))^(1/i) + ( i^(sin(1+i))((1+i)^i)]/[ i^(Ln(1+i))]
Answer:_______________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
Syntax:________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
f. the real part and imaginary part of (3 + i2)^(cos(3-j5)) - (1+i*sqrt(5))^(2-j)
Answer:_______________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
Syntax:________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
2. Create an m-file that will perform the basic math operations (addition, subtraction,
multiplication and division), square roots, logarithm, trigonometric and inverse
trigonometric functions of a complex numbers. (at least two rectangular form of complex
numbers will be the input for all of the given operations).
Answer:_______________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
Syntax:________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
If n > 0 is an integer and the four possible values of in are in+1 = i, in+2 = -1, in+3 = -i, in+4 =
1. Show that i1996 = in+4. Use the preceding result in creating an M-file.
Answer:_______________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
Syntax:________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________