Compare two matrix and delete the same rows

Say I have A= [1 2 3, 4 5 6, 6 7 8] and B= [4 5 7, 1 2 3, 7 6 4, 6 7 8]. How can I delete the rows in B that are the same with A? The result desired is B=[4 5 7, 7 6 4]
Thanks!

回答 (3 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 10 月 27 日
編集済み: Azzi Abdelmalek 2014 年 10 月 27 日

3 投票

A= [1 2 3; 4 5 6; 6 7 8]
B= [4 5 7; 1 2 3; 7 6 4; 6 7 8]
B(ismember(B,A,'rows'),:)=[]
David Sanchez
David Sanchez 2014 年 10 月 27 日

0 投票

A= [1 2 3; 4 5 6; 6 7 8];
B= [4 5 7; 1 2 3; 7 6 4; 6 7 8];
Lia = ismember(B,A,'rows');
B_new = B(~Lia,:)
B_new =
4 5 7
7 6 4

カテゴリ

ヘルプ センター および File ExchangeLanguage Fundamentals についてさらに検索

タグ

質問済み:

2014 年 10 月 27 日

回答済み:

2014 年 10 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by