all possible combination between matrices
Afficher commentaires plus anciens
I have 3 matrices with 2 columns but different number of lines, for example;
A=[[2,1],[0,6],[4,2]]
B = [[0,2],[1,1],[3,4],[0,5]
C = [[0,1],[5,4]]
i want to do all the combinations between,each pairs A/B and B/C for a difference of +1 or -1 between the sum of each pair, and they must have a number in common. For example if we take [2,1] from A, the sum is 3=2+1 now i have to find the next pair in B (if exist), see that [0,2] the sum is 2=0+2 and there is a number in common with [2,1] from A so i keep this pair and i dont keep [1,1] cause there is no common number, now if i go to C i will take [0,1] cause the sum is 1=0+1 and there is number in common with [1,1], passing from A to B, B to C respecting -1 sum difference and having always a number in common between the previous pair and the chosen one.
So the result in this case must be
[2,1], [0,2], [0,1]
1 commentaire
Bruno Luong
le 29 Oct 2020
"dont keep [1,1] cause there is no common number"
Why you said that? It has 1 in common with [2,1] from A.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Logical 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!