How can I find the roots of a symbolic polynimial
显示 更早的评论
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,
采纳的回答
更多回答(2 个)
Azzi Abdelmalek
2014-12-20
编辑:Azzi Abdelmalek
2014-12-20
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 个评论
Star Strider
2014-12-20
... then:
rb = roots(b);
to get the roots.
Ron Aditya
2014-12-20
Star Strider
2014-12-20
It would then be appropriate to Accept Azzi’s Answer.
John D'Errico
2014-12-20
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
2014-12-20
0 个投票
2 个评论
John D'Errico
2014-12-20
编辑:John D'Errico
2014-12-20
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
2014-12-26
类别
在 帮助中心 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!