How can I find all the possible options to make a certain number with three othere numbers
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Jens Keijser
am 25 Apr. 2018
Kommentiert: Ameer Hamza
am 30 Apr. 2018
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!
0 Kommentare
Akzeptierte Antwort
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, :) = [];
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices 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!