Permutations using multiple vectors of different lengths
Afficher commentaires plus anciens
I am trying to sum values of all permutations of values from multiple matrices of different lengths, and cannot find a way to use perms or for loops to do it.
v1=[10,600,800];
v2=[6,13];
v3=[5,2];
v4=[10,15,22,6];
v5=[12,5];
I want each matrix to contribute one (and only one) value to the permutation. Ultimately, I'm looking for a list that shows something like the following:
10+6+5+10+12=43
10+6+5+10+5=36
10+6+5+15+12=45
...
800+13+2+6+5=826
Even better would be if I could figure out how to get it to show the indexes used for each one as follows:
(1)+(1)+(1)+(1)+(1)=43
(1)+(1)+(1)+(1)+(2)=36
(1)+(1)+(1)+(2)+(1)=45
...
(3)+(2)+(2)+(4)+(2)=826
Any help is greatly appreciated. Thank you.
2 commentaires
John D'Errico
le 9 Sep 2019
Modifié(e) : John D'Errico
le 9 Sep 2019
help ndgrid
Think about what it does.
Robert Rieke
le 9 Sep 2019
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!