How to find different values of numbers in different matrices?

1 visualización (últimos 30 días)
Matias
Matias el 28 de Nov. de 2016
Respondida: Preethi el 28 de Nov. de 2016
Hello everybody. First of all, sorry for my english. I have a problem finding different values in some matrices. For example I have the matrices:
A=[1 2 3;7 6 7;0 5 6] B=[5 4 6;1 2 3;9 0 0] C=[4 5 4;1 2 3;7 3 2]
What I want to do is to search if the first row of A exists in B, and if it exists, to search for it in the next matrix, in this case C, and obtain the number of row in which they appear in each matrix. In my case I have a lot of matrices, not just 3, so I would like to do it with a for loop. I'm sure this can be done but I couldn't find a way to do it properly.
Thanks in advance..

Respuestas (1)

Preethi
Preethi el 28 de Nov. de 2016
hi,
you can use ismember() function. if the row exists the output will be one, else zero
ismember(A(1,:),B,'rows')

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by