nth root using sym class

2 visualizzazioni (ultimi 30 giorni)
John
John il 16 Nov 2011
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.

Risposte (1)

Andrew Newell
Andrew Newell il 17 Nov 2011
If you have R2011b, you could use solve, for example,
y = solve(x^3-5,'Principal value','true');

Community Treasure Hunt

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

Start Hunting!

Translated by