Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
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!

Akzeptierte Antwort

Ameer Hamza
Ameer Hamza am 25 Apr. 2018
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, :) = [];

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by