How can I find all the possible options to make a certain number with three othere numbers

1 回表示 (過去 30 日間)
Hello,
I have three weighing numbers for three algorithms. I would like to determine which weighing the algorithms need in order to make them work optimal combined.
For example: The total weighing is 3, so if the algorithms are equivalent each algorithm gets a weight of 1. But if there is one algorithm better then the others it gets a higher weighing, 2 for example. That means that there is only 1 weight left (2 + 1 = 3).
The weighing for the three algorithms is than 2-0-1. To determine the optimal weighing I need to try all the options:
3-0-0
2-1-0
2-0-1
1-1-1
0-3-0
1-2-0
0-2-1
0-0-3
And so on…
As you can see the sum is always 3. How can I make a matrix of some sort?
I thank you in advance!

採用された回答

Ameer Hamza
Ameer Hamza 2018 年 4 月 25 日
I am using FEX::permn. Download it and place it in MATLAB path. The following code will generate the required matrix.
choices = permn(0:3, 3);
index = sum(choices, 2)==3;
choices(~index, :) = [];

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by