Find the support of a mpol type variable

조회 수: 2 (최근 30일)
Aksh Chordia
Aksh Chordia 2022년 4월 18일
답변: SAI SRUJAN 2023년 10월 10일
Hi,
It is like a symbolic polynomial defined in MATLAB.
The polynomial is of the form:
f= 1+a1*x1+a2*x2+a3*x3+a4*x4+a5*x1^2+a6*x1*x2+a7*x1*x3+a8*x1*x4+a9*x2^2+a10*x2*x3+......so on
I need to get its support/order of monomial terms, i.e:
[0,0,0,0;
1,0,0,0;
0,1,0,0;
0,0,1,0;
0,0,0,1;
2,0,0,0;
1,1,0,0;
1,0,1,0,
1,0,0,1;
0,2,0,0;
0,1,1,0;
...... so on]
I can get the coeffecients using the coef() function.
But, I need its support/monomial orders.
Is there any matlab function to do so?
Thanks a lot for your help.
Regards

답변 (1개)

SAI SRUJAN
SAI SRUJAN 2023년 10월 10일
Hi Aksh Chordia,
I understand that you are trying to get the order of monomial terms for a given polynomial.
You can follow the below given example to resolve the issue.
syms a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 x1 x2 x3 x4
f= 1+a1*x1+a2*x2+a3*x3+a4*x4+a5*x1^2+a6*x1*x2+a7*x1*x3+a8*x1*x4+a9*x2^2+a10*x2*x3
f = 
ch=children(f)
ch = 1×11 cell array
{[a1*x1]} {[a2*x2]} {[a3*x3]} {[a4*x4]} {[a5*x1^2]} {[a9*x2^2]} {[a6*x1*x2]} {[a7*x1*x3]} {[a8*x1*x4]} {[a10*x2*x3]} {[1]}
order=[];
for i=1:length(ch)
exp=ch{i};
coeff=[polynomialDegree(exp,x1)];
coeff=[coeff polynomialDegree(exp,x2)];
coeff=[coeff polynomialDegree(exp,x3)];
coeff=[coeff polynomialDegree(exp,x4)];
order=[order;coeff];
end
order
order = 11×4
1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 2 0 0 0 0 2 0 0 1 1 0 0 1 0 1 0 1 0 0 1 0 1 1 0
You can use the "children" and "polynomialDegree" MATLAB function to get monomial order of a polynomial.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by