I need to create a vector from a symbolic polynomial function,but when i use sym2poly command, matlab tells me it is not a polynomial, how should i do?
1 次查看(过去 30 天)
显示 更早的评论
f1=(497*c1^2 + 497*c2^2 + 497*c3^2 + 11*(c3 + c1*c2)*(c2 - c1*c3)*(c1^2 + c2^2 + c3^2 + 1) + 497)^2/(103684*(c1^2 + c2^2 + c3^2 + 1)^2) + (136*c1^2 + 136*c2^2 + 136*c3^2 + (11*(c2 - c1*c3)*(c1^2 - c2^2 - c3^2 + 1)*(c1^2 + c2^2 + c3^2 + 1))/2 + 136)^2/(103684*(c1^2 + c2^2 + c3^2 + 1)^2) - 1;
sym2poly(f1)
Error using sym/sym2poly (line 30)
Not a polynomial
why matlab tells me this?
0 个评论
采纳的回答
Star Strider
2021-12-16
syms c1 c2 c3
sympref('AbbreviateOutput',false);
f1=(497*c1^2 + 497*c2^2 + 497*c3^2 + 11*(c3 + c1*c2)*(c2 - c1*c3)*(c1^2 + c2^2 + c3^2 + 1) + 497)^2/(103684*(c1^2 + c2^2 + c3^2 + 1)^2) + (136*c1^2 + 136*c2^2 + 136*c3^2 + (11*(c2 - c1*c3)*(c1^2 - c2^2 - c3^2 + 1)*(c1^2 + c2^2 + c3^2 + 1))/2 + 136)^2/(103684*(c1^2 + c2^2 + c3^2 + 1)^2) - 1
f1 = simplify(f1, 500)
[f1n, f1d] = numden(f1)
[f1n_cfs, f1n_trms] = coeffs(f1n) % Numerator Coefficients & Terms
[f1n_cfs_all, trms_all] = coeffs(f1, 'All')
That is as completely and thoroughly as it is possible to decompose this polynomial expression.
.
2 个评论
Star Strider
2021-12-17
As always, my pleasure!
The first coeffs call then:
[f1n_cfs, f1n_trms] = coeffs(f1n)
is likely as close as it is possible to get. MATLAB inteprets ‘polynomial’ as a univariate polynomial, the reason the sym2poly call fails.
.
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Polynomials 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!