필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
AS
AS 2019년 1월 17일
댓글: AS 2019년 1월 18일
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?

답변 (2개)

madhan ravi
madhan ravi 2019년 1월 17일
Position=find(ismember(A,B))

Walter Roberson
Walter Roberson 2019년 1월 17일
[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
AS
AS 2019년 1월 18일
Accepted..
Thank you very much. This code is working properly.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by