nth root using sym class
显示 更早的评论
Hello, I am new to Matlab and am trying to write a script to compute the roots of a quartic equation using analytical procedures. I am attempting to utilize my variables as sym objects so that I can control the numerical precision. The problem I am incurring, is that I have an expression that contains a cube root. It is my understanding that the nthroot() function is not compatible with the sym class. When I try to raise the term to the 1/3 power it produces complex roots when I need the real roots. Is there any way to compute the real cube root of a sym class variable?
P.S. I have found that I can convert to double for the desired expression and use the nthroot() function then convert back to the sym class, but I would prefer to keep everything sym if possible.
Thank You.
回答(1 个)
Andrew Newell
2011-11-17
If you have R2011b, you could use solve, for example,
y = solve(x^3-5,'Principal value','true');
类别
在 帮助中心 和 File Exchange 中查找有关 Assumptions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!