Generate Polynomial Expansion Orders as a matrix

Hi,
I have to create a polynomial, lets say, with dimensions =4 (x1,x2,x3,x4) and order =2.
Then the expansion becomes:
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 want these monomial orders in the format such as :
[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 am not able to figure out how to get that.
Therefore, requesting your help.

 Respuesta aceptada

Bruno Luong
Bruno Luong el 17 de Abr. de 2022
Editada: Bruno Luong el 17 de Abr. de 2022
You can use this FEX (also attached)
allVL1(4,2,'<=')
ans = 15×4
0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 2 0 0 1 1 0 0 2 0 0 1 0 1 0 1 1 0

4 comentarios

Aksh Chordia
Aksh Chordia el 17 de Abr. de 2022
Thanks a lot!
Aksh Chordia
Aksh Chordia el 18 de Abr. de 2022
Thanks a lot bruno.
But, I need the coefficients, in the specific order mentioned in the question.
Could you provide information on how to change that?
Bruno Luong
Bruno Luong el 18 de Abr. de 2022
Editada: Bruno Luong el 19 de Abr. de 2022
Do you want like this?
A=sortrows(allVL1(4,2,'<='),'descend');
[~,is]=sort(sum(A,2));
A=A(is,:)
A = 15×4
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
Aksh Chordia
Aksh Chordia el 19 de Abr. de 2022
Thanks a lot. It really helps :)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Preguntada:

el 17 de Abr. de 2022

Comentada:

el 19 de Abr. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by