Find the rows in matrix B that contain the two numbers in each row of matrix A, in every possible order
Mostra commenti meno recenti
I have a Nx2-matrix A, and a Mx3-matrix B, with M>N. I would like to find the rows in B that contain the two numbers in each row of matrix A, in every possible order.
Example:
A = [1 2,
2 5]
B = [1 5 6,
1 4 2,
2 9 3,
9 5 2]
Then, for the first row in A, the second row in B should be selected, and for the second row in A, the fourth one should be selected. Thus, the result should be:
C = [1 4 2,
9 5 2]
I have already solved it with for loops, find and ismember, but my matrices are quite big and it is a quite time consuming solution. Can you please help me?
1 Commento
Geoff Hayes
il 11 Apr 2015
Paula - please provide a sample of the code that you are using to determine the matrix C so that we can offer alternative suggestions. And also clarify what you mean by your matrices are quite big. What is the smallest and what is the largest matrix that you are concerned with?
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Resizing and Reshaping Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!