multiplication of combinaton values?

1 回表示 (過去 30 日間)
metin yilmaz
metin yilmaz 2023 年 9 月 13 日
コメント済み: Dyuman Joshi 2023 年 9 月 13 日
I would like to compute multiplcation of combination of numbers. For example if I have;
1, 2, 3, 4, 5 and want to find
Triple combinations of these numbers are
1,2, 3; 1,2,4; 1,2,5; 1,3,4; 1,3,5; ... etc How can find a=1*2*3; b=1*2*4; c=1*2*5; d=1*3*4; e=1*3*5 etc
a. How can I find all the multiplications of triple combinations, that is, a, b, c, d, etc
b. How can I easily and quickly find sum of a,b,c,d etc?

採用された回答

Dyuman Joshi
Dyuman Joshi 2023 年 9 月 13 日
編集済み: Dyuman Joshi 2023 年 9 月 13 日
You are looking for
b1 - prod and b2 - sum
  2 件のコメント
metin yilmaz
metin yilmaz 2023 年 9 月 13 日
I can use easily nchoosek but I don't know how to assign each result to a variable
Dyuman Joshi
Dyuman Joshi 2023 年 9 月 13 日
arr = nchoosek(1:5,3)
arr = 10×3
1 2 3 1 2 4 1 2 5 1 3 4 1 3 5 1 4 5 2 3 4 2 3 5 2 4 5 3 4 5
p = prod(arr,2)
p = 10×1
6 8 10 12 15 20 24 30 40 60
s = sum(p)
s = 225

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by