please let me have a help with the 'solve' command
1 次查看(过去 30 天)
显示 更早的评论
in the following is:
i = sqrt(-1)
pi= 3.1416
syms m fi real
assumeAlso( fi>=0 )
assumeAlso( fi<2*pi )
31-december-2016
Dear Sir
please let me have a help with the 'solve' command.
I have two running installation, one is matlab R2009a and the other is matlab R2016a.
So , i noted a different behavior of the command 'solve' between the two version of matlab when i attempt to solve this little equation:
m*exp(i*fi) = -2
with the constraint that both m and fi must be real.
This equation has only 2 sets of real solutions:
1st set : {m=-2 fi=0}
2nd set : {m=2 fi=pi}
now , the R2009a find exactly this sets of solutions, instead the R2016a not.
I tried including some parameter in the command string , such as 'IgnoreAnalyticCostraints' or 'MaxDegree', but i was not able to force R20016a to obtain these complete solutions.
Please take a look at the image screenshot here enclosed where show both Matlab versions at work , with the different solutions obtained, note R2061a obtain only the 1st set : {m=-2 fi=0}
please let me know the right steps for obtain the solution {m=2 fi=pi} also in the R2016a
Thank you
Kind Regards
0 个评论
采纳的回答
Walter Roberson
2017-1-1
"This equation has only 2 sets of real solutions:"
That turns out not to be correct.
[FI, M, P, C] = solve(m*exp(i*fi)==-2, 'ReturnConditions', true)
FI =
pi + 2*pi*k
2*pi*k
M =
2
-2
P =
k
C =
in(k, 'integer')
in(k, 'integer')
so there are real solutions for every odd multiple of pi with M = 2, and there are real solutions for every even multiple of pi with M = -2
The fact that solve() could not return those in the forms of command you used is a bug, which I have just reported with a number of test cases showing various weaknesses.
The best approach so far is to use the multiple output form, allowing one output for each variable, plus one output for parameters, plus one output for conditions, and in solve() to list all of the variables in the order you want them output, and use ReturnConditions true
更多回答(1 个)
Star Strider
2017-1-1
There have probably been some version changes in the solve function in the last 7 years.
This works (in R2016b):
syms m fi real
Eqn = m*exp(i*fi) == -2;
[m,fi] = solve(Eqn)
m =
pi
0
fi =
2
-2
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!