Find the support of a mpol type variable

4 次查看(过去 30 天)
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