find dublicated value in a column and return the whole row

3 次查看(过去 30 天)
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,:)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Climate Science and Analysis 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by