find dublicated value in a column and return the whole row

조회 수: 1 (최근 30일)
Martin
Martin 2018년 10월 22일
댓글: madhan ravi 2018년 10월 22일
imagine I have this:
A = [ 1 ; 3 ; 5 ; 6 ; 9 ]
and
B = [ 1 4 ; 2 7 ; 3 5 ; 9 10 ]
I need to end up with:
C = [ 1 4 ; 3 5 ; 9 10 ]
In B(:,1) column I need to find those from A that match, and if so, return the full rows of B. Hope I am clear

채택된 답변

madhan ravi
madhan ravi 2018년 10월 22일
A = [ 1 ; 3 ; 5 ; 6 ; 9 ]
B = [ 1 4 ; 2 7 ; 3 5 ; 9 10 ]
idx=ismember(B(:,1),A)
C = B(idx,:)
  댓글 수: 3
Martin
Martin 2018년 10월 22일
thanks bro

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

추가 답변 (0개)

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by