Obtaining n^th order polynomial combinations in an array

3 Ansichten (letzte 30 Tage)
Shreshtha Chaturvedi
Shreshtha Chaturvedi am 20 Dez. 2022
Bearbeitet: KSSV am 20 Dez. 2022
Hi, I want to obtain an array consisting of all the possible combinations of polynomials upto n^(th) order. For example, for order 2, the array would look like
[1, x(1), x(2), x(3), x(4), x(5), x(6), x(1)*x(1), x(1)*x(2), x(1)*x(3), x(1)*x(4), x(1)*x(5), x(1)*x(6), x(2)*x(2), x(2)*x(3), x(2)*x(4), x(2)*x(5), x(2)*x(6), x(3)*x(3), x(3)*x(4), x(3)*x(5), x(3)*x(6), x(4)*x(4), x(4)*x(5), x(4)*x(6), x(5)*x(5),x(5)*x(6), x(6)*x(6)]
Whereas for order 3, it will look like
[1, x(1), x(2), x(3), x(4), x(5), x(6), x(1)*x(1), x(1)*x(2), x(1)*x(3), x(1)*x(4), x(1)*x(5),
x(1)*x(6), x(2)*x(2), x(2)*x(3), x(2)*x(4), x(2)*x(5), x(2)*x(6), x(3)*x(3), x(3)*x(4),
x(3)*x(5), x(3)*x(6), x(4)*x(4), x(4)*x(5), x(4)*x(6), x(5)*x(5),x(5)*x(6),
x(6)*x(6), x(1)*x(1)*x(1), x(1)*x(1)*x(2), x(1)*x(1)*x(3), x(1)*x(1)*x(4),
x(1)*x(1)*x(5), x(1)*x(1)*x(6), x(1)*x(2)*x(2), x(1)*x(2)*x(3), x(1)*x(2)*x(4),
x(1)*x(2)*x(5), x(1)*x(2)*x(6), x(1)*x(3)*x(3), x(1)*x(3)*x(4), x(1)*x(3)*x(5),
x(1)*x(3)*x(6), x(1)*x(4)*x(4), x(1)*x(4)*x(5), x(1)*x(4)*x(6), x(1)*x(5)*x(5),
x(1)*x(5)*x(6), x(1)*x(6)*x(6), x(2)*x(2)*x(2), x(2)*x(2)*x(3), x(2)*x(2)*x(4),
x(2)*x(2)*x(5), x(2)*x(2)*x(6),x(2)*x(3)*x(3), x(2)*x(3)*x(4), x(2)*x(3)*x(5), x(2)*x(3)*x(6),
x(2)*x(4)*x(4), x(2)*x(4)*x(5), x(2)*x(4)*x(6), x(2)*x(5)*x(5), x(2)*x(5)*x(6), x(2)*x(6)*x(6),
x(3)*x(3)*x(3),x(3)*x(3)*x(4), x(3)*x(3)*x(5), x(3)*x(3)*x(6), x(3)*x(4)*x(4), x(3)*x(4)*x(5),
x(3)*x(4)*x(6), x(3)*x(5)*x(5), x(3)*x(5)*x(6), x(3)*x(6)*x(6), x(4)*x(4)*x(4), x(4)*x(4)*x(5),
x(4)*x(4)*x(6), x(4)*x(5)*x(5),x(4)*x(5)*x(6), x(4)*x(6)*x(6), x(5)*x(5)*x(5), x(5)*x(5)*x(6),
x(5)*x(6)*x(6), x(6)*x(6)*x(6)]
So far, I am manually defining such arrays, but as you can see, it is very tedious. Is there a way to code this for any random order n? Thank you for all the help!

Antworten (1)

KSSV
KSSV am 20 Dez. 2022
Bearbeitet: KSSV am 20 Dez. 2022
REad about nchoosek
You may also refer to the below file exchange: https://in.mathworks.com/matlabcentral/fileexchange/9029-nmultichoosek

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by