Let's run through a few elementary manipulations of complex numbers in Matlab:
>> x = 1;
>> y = 2;
>> z = x + j * y
z =
1.0000 + 2.0000i
>> 1/z
ans =
0.2000 - 0.4000i
>> z^2
ans =
-3.0000 + 4.0000i
>> conj(z)
ans =
1.0000 - 2.0000i
>> z*conj(z)
ans =
5
>> abs(z)^2
ans =
5.0000
>> norm(z)^2
ans =
5.0000
>> angle(z)
ans =
1.1071
Now let's do polar form:
>> r = abs(z)
r =
2.2361
>> theta = angle(z)
theta =
1.1071
Curiously,
is not defined by default in Matlab (though it is in
Octave). It can easily be computed in Matlab as e=exp(1).
Below are some examples involving imaginary exponentials:
>> r * exp(j * theta)
ans =
1.0000 + 2.0000i
>> z
z =
1.0000 + 2.0000i
>> z/abs(z)
ans =
0.4472 + 0.8944i
>> exp(j*theta)
ans =
0.4472 + 0.8944i
>> z/conj(z)
ans =
-0.6000 + 0.8000i
>> exp(2*j*theta)
ans =
-0.6000 + 0.8000i
>> imag(log(z/abs(z)))
ans =
1.1071
>> theta
theta =
1.1071
>>
Some manipulations involving two complex numbers:
>> x1 = 1; >> x2 = 2; >> y1 = 3; >> y2 = 4; >> z1 = x1 + j * y1; >> z2 = x2 + j * y2; >> z1 z1 = 1.0000 + 3.0000i >> z2 z2 = 2.0000 + 4.0000i >> z1*z2 ans = -10.0000 +10.0000i >> z1/z2 ans = 0.7000 + 0.1000i
Another thing to note about Matlab is that the transpose operator ' (for vectors and matrices) conjugates as well as transposes. Use .' to transpose without conjugation:
>>x = [1:4]*j
x =
0 + 1.0000i 0 + 2.0000i 0 + 3.0000i 0 + 4.0000i
>> x'
ans =
0 - 1.0000i
0 - 2.0000i
0 - 3.0000i
0 - 4.0000i
>> x.'
ans =
0 + 1.0000i
0 + 2.0000i
0 + 3.0000i
0 + 4.0000i
>>