필터 지우기
필터 지우기

Finding the index of a matrix corresponding to a particular column of another matrix

조회 수: 1 (최근 30일)
I have two matrices like, A= [4 12 ; 2 6] and B = [9 4 8 12 ; 2 2 4 6] I want get the relevant index of B corresponding to the 1st column in matrix A. (i.e- first column of A is 4 and 2. And the index corresponding to that in matrix A is index 2 )
  댓글 수: 2
Eranja Noopehewa
Eranja Noopehewa 2018년 10월 30일
편집: Matt J 2018년 10월 30일
first column of A is 4 and 2. And the index corresponding to that column in matrix A is index 2

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

채택된 답변

Rik
Rik 2018년 10월 30일
You can try this:
A= [4 12 ; 2 6];
B = [9 4 8 12 ; 2 2 4 6];
selected_col=1;
col_in_B=find(all(A(:,selected_col)==B,1));

추가 답변 (2개)

madhan ravi
madhan ravi 2018년 10월 30일
A= [4 12 ; 2 6]
B = [9 4 8 12 ; 2 2 4 6]
idx=find(any(A(:,1)==B))
  댓글 수: 4

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


Matt J
Matt J 2018년 10월 30일
[~,idx]=ismember(A(:,1).',B.','rows')

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by