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?

채택된 답변

Star Strider
Star Strider 2021년 12월 16일
One option is to use the coeffs function —
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 = 
f1 = simplify(f1, 500)
f1 = 
[f1n, f1d] = numden(f1)
f1n = 
f1d = 
414736
[f1n_cfs, f1n_trms] = coeffs(f1n) % Numerator Coefficients & Terms
f1n_cfs = 
f1n_trms = 
[f1n_cfs_all, trms_all] = coeffs(f1, 'All')
f1n_cfs_all(:,:,1) = 
f1n_cfs_all(:,:,2) = 
f1n_cfs_all(:,:,3) = 
f1n_cfs_all(:,:,4) = 
f1n_cfs_all(:,:,5) = 
f1n_cfs_all(:,:,6) = 
f1n_cfs_all(:,:,7) = 
trms_all(:,:,1) = 
trms_all(:,:,2) = 
trms_all(:,:,3) = 
trms_all(:,:,4) = 
trms_all(:,:,5) = 
trms_all(:,:,6) = 
trms_all(:,:,7) = 
That is as completely and thoroughly as it is possible to decompose this polynomial expression.
.
  댓글 수: 2
sebastiano della gatta
sebastiano della gatta 2021년 12월 17일
thank you for the answer but I don't want to completely decompose the polynomial, I just need the vector of this function because then I have to apply the grobner bases to arrive at my solution.
Star Strider
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개)

sebastiano della gatta
sebastiano della gatta 2021년 12월 17일
thank you. I have the last question. Can i compute groebner basis from f1? (The first function that I put in the first question).
  댓글 수: 3

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Polynomials에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by