Find the support of a mpol type variable
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I have a polynomial of type mpol (ref: GloptiPoly 3: moments, optimization and semidefinite programming (archives-ouvertes.fr)).
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
0 commentaires
Réponses (1)
SAI SRUJAN
le 10 Oct 2023
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
ch=children(f)
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
You can use the "children" and "polynomialDegree" MATLAB function to get monomial order of a polynomial.
0 commentaires
Voir également
Catégories
En savoir plus sur Linear Algebra dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
