Solve eqn and get real solution
40 次查看(过去 30 天)
显示 更早的评论
I want to solve an eqn and get the real solution. This is the code:
...
s=solve(R_);
...
And this is solution: s =
0.3971412063699492853956558622094
-0.8763850946630804323385057262195
- 0.13537805585343442652857506799495 - 0.83663803641655759940578883730279*i
- 0.13537805585343442652857506799495 + 0.83663803641655759940578883730279*i
As you can see "s" has two solutions are real (0.3971 and -0.87638) and two imaginary (with i). The real solution is needed. Which command can be used in this case? Give the example is helpful.
0 个评论
回答(2 个)
Torsten
2015-10-8
syms s
y=-(2*((622930548819969075*s^4)/147573952589676412928 - (45369884049352485*s^3)/576460752303423488 + (69272938975695885*s^2)/144115188075855872 - (2396595835289415*s)/2251799813685248 + 2755552026909489/4503599627370496)*((124586109763993815*s^5)/147573952589676412928 - (45369884049352485*s^4)/2305843009213693952 + (23090979658565295*s^3)/144115188075855872 - (2396595835289415*s^2)/4503599627370496 + (2755552026909489*s)/4503599627370496 - 8557508135623347/36028797018963968) + 2*((10728642163125225*s^3)/288230376151711744 - (938834444243547705*s^4)/295147905179352825856 - (72312578171060145*s^2)/576460752303423488 + (3614047914544827*s)/36028797018963968 + 17054950948113267/1152921504606846976)*((10728642163125225*s^4)/1152921504606846976 - (187766888848709541*s^5)/295147905179352825856 - (24104192723686715*s^3)/576460752303423488 + (3614047914544827*s^2)/72057594037927936 + (17054950948113267*s)/1152921504606846976 - 1819839641949093/72057594037927936))/(2*(((17054950948113267*s)/1152921504606846976 + (3614047914544827*s^2)/72057594037927936 - (24104192723686715*s^3)/576460752303423488 + (10728642163125225*s^4)/1152921504606846976 - (187766888848709541*s^5)/295147905179352825856 - 1819839641949093/72057594037927936)^2 + ((2755552026909489*s)/4503599627370496 - (2396595835289415*s^2)/4503599627370496 + (23090979658565295*s^3)/144115188075855872 - (45369884049352485*s^4)/2305843009213693952 + (124586109763993815*s^5)/147573952589676412928 - 8557508135623347/36028797018963968)^2)^(3/2))
m=solve(y,s)
ix=arrayfun(@isreal,double(m));
m=m(ix);
disp(m);
Best wishes
Torsten.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!