How can I find the roots of a symbolic polynimial
Mostra commenti meno recenti
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,
Risposta accettata
Più risposte (2)
Azzi Abdelmalek
il 20 Dic 2014
Modificato: Azzi Abdelmalek
il 20 Dic 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 Commenti
Star Strider
il 20 Dic 2014
... then:
rb = roots(b);
to get the roots.
Ron Aditya
il 20 Dic 2014
Star Strider
il 20 Dic 2014
It would then be appropriate to Accept Azzi’s Answer.
John D'Errico
il 20 Dic 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
il 20 Dic 2014
0 voti
2 Commenti
John D'Errico
il 20 Dic 2014
Modificato: John D'Errico
il 20 Dic 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
il 26 Dic 2014
Categorie
Scopri di più su Symbolic Math Toolbox in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!