how remove duplicate rows ?

9 Ansichten (letzte 30 Tage)
Firas
Firas am 21 Mai 2014
Bearbeitet: the cyclist am 21 Mai 2014
I dont knew if we can have a script for that if we have
A=[ 1,2,3;
42,0,1;
14,2,4;
2,3,5;
1,0,0]
B=[42,0,1;
1,0,0]
i want C
C=[ 1,2,3;
14,2,4;
2,3,5]
thanks
  1 Kommentar
the cyclist
the cyclist am 21 Mai 2014
Bearbeitet: the cyclist am 21 Mai 2014
Note that the difference between my answer and Andrei's is how to handle the case where there are rows in B that are not in A. My solution will include those rows in C, and Andrei's will not.
Azzi's is different still, in that it handles replicated rows from A differently. My and Andrei's solution will keep only the unique rows, while Azzi's will keep duplicate rows from A.

Melden Sie sich an, um zu kommentieren.

Antworten (3)

the cyclist
the cyclist am 21 Mai 2014
Bearbeitet: the cyclist am 21 Mai 2014
C = setxor(A,B,'rows','stable')

Andrei Bobrov
Andrei Bobrov am 21 Mai 2014
C = setdiff(A,B,'rows','stable')

Azzi Abdelmalek
Azzi Abdelmalek am 21 Mai 2014
C=A(~ismember(A,B,'rows'),:);

Community Treasure Hunt

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

Start Hunting!

Translated by