How can I find the roots of a symbolic polynimial
Ältere Kommentare anzeigen
I create a symbolic transfer function matrix. I find its inverse. The first element of the matrix is a polynomial. Note that this polynomial is symbolic so no operation can be done on it. I want to convert this to a polynomial and find the roots. How should I go about this? Thanks.
aa =
- 30*s^4 + 300*s^3
>> coeffs(aa)
ans =
[ 300, -30]
Here aa is the polynomial I go ahead and extract the coefficients and then i can do a "aa=double(aa)" to convert it to double. And then find the roots. But the problem is When I do the coeffs(aa) i should get [-30 300 0 0] and not [300 -30]. Even if I get [0 0 300 -30], I can get my way through. But the issue is i need those missing zeros (coefficients of s^2 and s^1).
Thanks,
Akzeptierte Antwort
Weitere Antworten (2)
Azzi Abdelmalek
am 20 Dez. 2014
Bearbeitet: Azzi Abdelmalek
am 20 Dez. 2014
use sym2poly instead of coeffs
syms s
aa=- 30*s^4 + 300*s^3
b=sym2poly(aa)
If you want another order
c=fliplr(b)
4 Kommentare
Star Strider
am 20 Dez. 2014
... then:
rb = roots(b);
to get the roots.
Ron Aditya
am 20 Dez. 2014
Star Strider
am 20 Dez. 2014
It would then be appropriate to Accept Azzi’s Answer.
John D'Errico
am 20 Dez. 2014
Why would you recommend accepting an answer this is less complete, that suggests solving the problem using a less accurate solution, when a better solution is suggested in a different response?
Ron Aditya
am 20 Dez. 2014
0 Stimmen
2 Kommentare
John D'Errico
am 20 Dez. 2014
Bearbeitet: John D'Errico
am 20 Dez. 2014
It works for me.
clear
syms s
p=30*s^2+40*s+9
p =
30*s^2 + 40*s + 9
solve(p)
ans =
- 130^(1/2)/30 - 2/3
130^(1/2)/30 - 2/3
solve(p,s)
ans =
- 130^(1/2)/30 - 2/3
130^(½)/30 - 2/3
vpa(solve(p,s))
ans =
-1.0467251416997126597120163418556
-0.28660819163362067362131699147775
I would suggest that you have done something wrong. Perhaps you redefined the variable s or p somehow before you called solve. Perhaps you defined a function called solve. Perhaps you defined those variables in some other way, and were not careful when you did that test.
I would suggest using clear before you make that test if you are not sure what you are doing. If all else fails, then you might try this:
which solve -all
Is it possible that you moved some of the functions outside of the symbolic toolbox? This is a very basic operation with that toolbox, so if it does not work as I have shown, then it means you may need to reinstall that toolbox.
Ron Aditya
am 26 Dez. 2014
Kategorien
Mehr zu Symbolic Math Toolbox finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!