MATLAB Answers

Convert a Complex Number to exponential real

16 views (last 30 days)
Jogger
Jogger on 16 Jun 2021
Edited: Jogger on 6 Jul 2021
Hi
I am looking for help to calculate value of a complex number say x = 2 +1j*5 using exponential function
Thanks you

Accepted Answer

Robert U
Robert U on 16 Jun 2021
Hi Jogger,
have a look at Euler's formula (https://en.wikipedia.org/wiki/Euler's_formula).
x = 2 + 1j * 5;
r = sqrt(real(x)^2 + imag(x)^2);
phi = atan2(imag(x),real(x));
fprintf(1,'z = r * exp(j*phi)\nr = %.2f\nphi = %.2f',r,phi)
z = r * exp(j*phi) r = 5.39 phi = 1.19
Kind regards,
Robert

More Answers (1)

dpb
dpb on 16 Jun 2021
MATLAB has builtin functions abs (or hypot()) and angle() for the above explicit implementations...
>> x=complex(2,5);
>> cmplx2exp=@(x) deal(abs(x),angle(x));
>> [r,theta]=cmplx2exp(x)
r =
5.3852
theta =
1.1903
>>
  3 Comments
Jogger
Jogger on 17 Jun 2021
I ma having following output
x(i) | exp(i) | log(i) | expreal(y1(i)) expimag(y1(i))| logreal(z1(i)) logimag(z1(i))|
----------------+---------------+---------------+---------------+---------------+---------------+---------------+
-6.283185 | 0.00187 | -6.283185 | 1.000000 +0.000000| 0.000000 +1.570796|
-5.283185 | 0.00508 | -5.283185 | 0.540302 +0.841471| -0.000000 +2.570796|
-4.283185 | 0.01380 | -4.283185 | -0.416147 +0.909297| 0.000000 -2.712389|
-3.283185 | 0.03751 | -3.283185 | -0.989992 +0.141120| 0.000000 -1.712389|
-2.283185 | 0.10196 | -2.283185 | -0.653644 -0.756802| -0.000000 -0.712389|
-1.283185 | 0.27715 | -1.283185 | 0.283662 -0.958924| -0.000000 +0.287611|
-0.283185 | 0.75338 | -0.283185 | 0.960170 -0.279415| -0.000000 +1.287611|
0.716815 | 2.04790 | 0.716815 | 0.753902 +0.656987| 0.000000 +2.287611|
1.716815 | 5.56677 | 1.716815 | -0.145500 +0.989358| 0.000000 -2.995574|
2.716815 | 15.13205 | 2.716815 | -0.911130 +0.412118| -0.000000 -1.995574|
3.716815 | 41.13316 | 3.716815 | -0.839072 -0.544021| -0.000000 -0.995574|
4.716815 | 111.81153 | 4.716815 | 0.004426 -0.999990| 0.000000 +0.004426|
5.716815 | 303.93525 | 5.716815 | 0.843854 -0.536573| -0.000000 +1.004426|

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!