フィルターのクリア

Obtaining n^th order polynomial combinations in an array

2 ビュー (過去 30 日間)
Shreshtha Chaturvedi
Shreshtha Chaturvedi 2022 年 12 月 20 日
編集済み: KSSV 2022 年 12 月 20 日
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!

回答 (1 件)

KSSV
KSSV 2022 年 12 月 20 日
編集済み: KSSV 2022 年 12 月 20 日
REad about nchoosek
You may also refer to the below file exchange: https://in.mathworks.com/matlabcentral/fileexchange/9029-nmultichoosek

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by