select specific row in a matrix

1 回表示 (過去 30 日間)
NA
NA 2019 年 4 月 15 日
回答済み: madhan ravi 2019 年 4 月 15 日
A=[1;2;237;250;800;805];
B=[1,1,0.5;2,1,2;3,1,1;4,1,3;16,1,1;237,4,5;240,2,3;250,2,4;280,6,7;800,4,5;805,7,8];
I want to select A in B
result should be
New_B=[1,1,0.5;2,1,2;237,4,5;250,2,4;800,4,5;805,7,8];
I use this code
New_B=B(unique(A)==B(:,1),:)
but have this error
Matrix dimensions must agree.

採用された回答

madhan ravi
madhan ravi 2019 年 4 月 15 日
B(ismember(B(:,1),A),:)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by