Find the rows in matrix B that contain the two numbers in each row of matrix A, in every possible order
Mostrar comentarios más antiguos
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 comentario
Geoff Hayes
el 11 de Abr. de 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?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Resizing and Reshaping Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!