How can I find all the possible options to make a certain number with three othere numbers
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Jens Keijser
le 25 Avr 2018
Commenté : Ameer Hamza
le 30 Avr 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 commentaires
Réponse acceptée
Ameer Hamza
le 25 Avr 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!