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!