フィルターのクリア

match row and column

1 回表示 (過去 30 日間)
Tanmoyee Bhattacharya
Tanmoyee Bhattacharya 2016 年 2 月 25 日
編集済み: Stephen23 2016 年 2 月 25 日
I have one matrix
a=
1 3 0
2 5 0
3 7 0
4 8 0
5 10 0
and another is
b=
5 10
3 7
I want to do find(a(:,1)=b(:,1) & a(:,2)==b(:,2) so that
5 10 0
3 7 0

採用された回答

Stephen23
Stephen23 2016 年 2 月 25 日
編集済み: Stephen23 2016 年 2 月 25 日
You can use ismember to generate the logical indices. In the same order as a:
>> idx = ismember(a(:,1:2),b,'rows');
>> a(idx,:)
ans =
3 7 0
5 10 0
Or in the same order as b:
>> [~,idx] = ismember(b,a(:,1:2),'rows');
>> a(idx,:)
ans =
5 10 0
3 7 0

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by