In this part we examine how MATLAB deals with complex numbers.
The imaginary unit is denoted by i(lower-case "eye") in MATLAB. So, to assign 5+3i to a, enter
a = 5 + 3*i
Enter the following complex numbers in your worksheet:
a = 5 + 3i
b = 2 - 4i
c = - 3 + i
d = - 2 - 4i
Enter the following lines of MATLAB code, and describe what each of the MATLAB commands does. Check by trying with a number different from a.
real(a)
imag(a)
abs(a)
conj(a)
The angle function needs special attention. Enter each of the following:
angle(a)
angle(b)
angle(c)
angle(d)
What is the range of the angle function? Describe carefully what the angle function does.
It is often useful to consider complex numbers
in their polar form (Theta, R). The built-in MATLAB function "cart2pol" converts
cartesian coordinates (x,y) to polar coordinates (Theta,R).
Let's convert the complex number a from above to its polar form.
Enter:
[Theta_a, R_a] = cart2pol( real(a), imag(a) )
Repeat this for b to get [Theta_b, R_b].
The built-in MATLAB
function "pol2cart" converts polar coordinates (Theta,R) to cartesian coordinates (x,y).
Let's see if we can recover our original a. Enter:
[x, y] = pol2cart(Theta_a, R_a);
new_a = x + y*i
Repeat this for [Theta_b, R_b] to get the original b back.
Calculate the polar form of a*b.
How is the polar form of the product related to the polar forms of the factors?