How to solve exponential equation ?

1 次查看(过去 30 天)
I have one vector theta of order (Kx1). Each element in this vector, theta(k), need to equate with an exponential term and need to find the corresponding angle,x, where the angle has a constraint that it lies between 0 and 2pi. .
Equation :
theta(k)=exp( j* x)
Constraint:
I wrote the following code.
syms x
g=theta-exp(1j.*x)==0
assume(x >= 0)
assume(x <= 2*pi)
sol=solve(g,x);
If K=10, when I am running this code with
theta =[ 1.0000; 1.0000; -55.1130; 1.0000; 1.0000; 1.0000; 1.0000; 1.0000; 1.0000; -16.2240;] ;
Matlab gives result as
g =
2251796802401363/2251799813685248 - exp(x*1i) == 0
562949107552839/562949953421312 - exp(x*1i) == 0
- exp(x*1i) - 1939115653123881/35184372088832 == 0
9007195107837447/9007199254740992 - exp(x*1i) == 0
9007194646232807/9007199254740992 - exp(x*1i) == 0
9007192947970379/9007199254740992 - exp(x*1i) == 0
9007194531439999/9007199254740992 - exp(x*1i) == 0
2251797866067969/2251799813685248 - exp(x*1i) == 0
9007190556467521/9007199254740992 - exp(x*1i) == 0
- exp(x*1i) - 4566663135924699/281474976710656 == 0
sol =
Empty sym: 0-by-1
But i feel solution of x should be obtained. How to rectify this error? Help required. Thanks in advance.

回答(1 个)

Walter Roberson
Walter Roberson 2020-8-7
The empty answer is correct.
When you solve(), you are asking for the set of values for variables that makes all of the equations true simultaneously. But your equations are all in the single variable x, and there is no one value of x that can satisfy all of the equations simultaneously, so the empty answer is correct.
You should be solving the equations individually:
sol = arrayfun(@solve, g, 'uniform', 0)
The 3rd and 10th entries for the result will be empty. The reason for that is not that there is no value of x that satisfies the equation, but rather that there is no value for x that satisfies the constraints and the equations generated by those theta -- those particular theta require complex-valued x, such as pi - log(55113/1000)*1i
  2 个评论
Syam MS
Syam MS 2020-8-7
编辑:Syam MS 2020-8-7
ok. Regarding 3rd and 10th entries in theta, i will check the matlab code again to rectify the error.
But even when using
sol = arrayfun(@solve, g, 'uniform', 0)
solution that is obtained for other entries is not as expected.
sol =
10×1 cell array
{0×1 sym}
{0×1 sym}
{0×1 sym}
{0×1 sym}
{0×1 sym}
{0×1 sym}
{0×1 sym}
{0×1 sym}
{0×1 sym}
{0×1 sym}
Walter Roberson
Walter Roberson 2020-8-8
theta =[ 1.0000; 1.0000; -55.1130; 1.0000; 1.0000; 1.0000; 1.0000; 1.0000; 1.0000; -16.2240;] ;
syms x
g = theta-exp(1j.*x)==0;
assume(x >= 0)
assume(x <= 2*pi)
sol = arrayfun(@solve, g, 'uniform', 0);
celldisp(sol)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by