Please tell me what's wrong here with the exp (1j*theta)

I am trying to find the theta part from an exponential value.
Suppose, i take a variable
z=exp(1i*5);
so this will give me
z =
0.2837 - 0.9589i
Now i want to find that "5" from this value. So, i go with this "angle(z)" and matlab shows
ans =
-1.2832
Shouldn't it be 5, according to theory ??
Or if i go with the eular formula like, exp(i*theta)= cos(theta) + i*sin(theta)
so, theta= atan(0.2837/-0.9589) = -0.2877 !!
How do i get the theta=5 back, i don't know if i am missing something.

 採用された回答

John Doe
John Doe 2013 年 5 月 11 日
編集済み: John Doe 2013 年 5 月 11 日

0 投票

The reason is that:
5 rad = -1.2832 rad % (-1.2832 + 2*pi = 5)
That is:
x = x + n*2*pi; % where x is an angle in radians, and n is an integer.
Matlab will always give you values between +/- pi.
And you use Eular the wrong way around: tan = sin/cos, not cos/sin.
=)
- Rob

6 件のコメント

Mohammad Mahmudul Hasan
Mohammad Mahmudul Hasan 2013 年 5 月 11 日
5 rad = -1.2832 rad ?? you mean -1.2832 degree ?? but 5 radians = 286.478 degrees, i think.. or please tell me how do i get the 5 back.
John Doe
John Doe 2013 年 5 月 11 日
編集済み: John Doe 2013 年 5 月 11 日
No, I meant what I said. If you want 5 back, you need to add 2*n*pi, where n is an integer (in this case 1). Why would you want an angle that is more than 2*pi? That's the equivalent of an angle larger than 360 degrees.
If you absolutely need the number you used in the exponential function, I recommend you save it as a variable, and use that variable later in your work.
x = 5;
z = exp(1i*x);
Mohammad Mahmudul Hasan
Mohammad Mahmudul Hasan 2013 年 5 月 11 日
yeah, you are right it's y/x not the other way around. thanks you for help.
John Doe
John Doe 2013 年 5 月 11 日
If the answer provided is sufficient, please accept it. If not, explain what parts are not clear, and you will get additional help (from me or others). =)
Mohammad Mahmudul Hasan
Mohammad Mahmudul Hasan 2013 年 5 月 11 日
thank you, for your reply, and as you've mentioned .. that i could save this variable to use later, but i will actually send this variable as a signal of "exp(1j*x)" to the receiver and receiver will extract 5 from this. So, i can't actually save it as a variable.
anyway, what i understood is this
>> angle(exp(1j*5)) +2*pi
ans =
5
>> angle(exp(1j*4)) +2*pi
ans =
4.0000
It works here but, when i go for 1 or 2...
>> angle(exp(1j*2)) +2*pi
ans =
8.2832
>> angle(exp(1j*1)) +2*pi
ans =
7.2832
shouldn't this be 1 and 2, as it worked for 4 and 5 ??
John Doe
John Doe 2013 年 5 月 11 日
No. Valid angles are in the area (-pi < x < pi). Since 4 and 5 are outside this area, the angles are not 4 and 5 (but -1.283.. etc). However, 1 and 2 are within the valid area, thus the angle is equal to 1 and 2 (without adding any +/-k*2*pi).

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by