How to solve exponential equation ?
1 view (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Walter Roberson
on 7 Aug 2020
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 Comments
Walter Roberson
on 8 Aug 2020
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)
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!