Compare two matrix and delete the same rows

13 Ansichten (letzte 30 Tage)
Patrick
Patrick am 27 Okt. 2014
Beantwortet: Andrei Bobrov am 27 Okt. 2014
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!

Antworten (3)

Azzi Abdelmalek
Azzi Abdelmalek am 27 Okt. 2014
Bearbeitet: Azzi Abdelmalek am 27 Okt. 2014
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'),:)=[]

Andrei Bobrov
Andrei Bobrov am 27 Okt. 2014
setdiff(B,A,'rows')

David Sanchez
David Sanchez am 27 Okt. 2014
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

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by