Borrar filtros
Borrar filtros

How to find out the column number of a same element of one matrix in other matrix?

2 visualizaciones (últimos 30 días)
If I have two different matrices, having some same element i.e. A=[23 45 6 7 89 12 3 6 7 8] and B=[6 7 45 12]. Now, in A and B some elements are same like 45, 6, 7 and 12. Now, I want to know/assign the column number of theses same elements (45, 6, 7 and 12) in A matrix. That means The column of each element of B in A matrix. Where the same elements are positioned (i.e. column) in matix A?

Respuestas (2)

madhan ravi
madhan ravi el 17 de En. de 2019
Position=find(ismember(A,B))

Walter Roberson
Walter Roberson el 17 de En. de 2019
[present, idx] = ismember(B, A);
present will be false for any element of B that is not in A. Otherwise B(K) == A(idx(K)) -- so idx is the entry number within A.
  3 comentarios
AS
AS el 18 de En. de 2019
Accepted..
Thank you very much. This code is working properly.

Iniciar sesión para comentar.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by