How can I find all the possible options to make a certain number with three othere numbers
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Jens Keijser
il 25 Apr 2018
Commentato: Ameer Hamza
il 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 Commenti
Risposta accettata
Ameer Hamza
il 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!