how remove duplicate rows ?

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

the cyclist
the cyclist 2014년 5월 21일
편집: the cyclist 2014년 5월 21일
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.

댓글을 달려면 로그인하십시오.

답변 (3개)

the cyclist
the cyclist 2014년 5월 21일
편집: the cyclist 2014년 5월 21일

1 개 추천

C = setxor(A,B,'rows','stable')
Andrei Bobrov
Andrei Bobrov 2014년 5월 21일

0 개 추천

C = setdiff(A,B,'rows','stable')
Azzi Abdelmalek
Azzi Abdelmalek 2014년 5월 21일

0 개 추천

C=A(~ismember(A,B,'rows'),:);

카테고리

질문:

2014년 5월 21일

편집:

2014년 5월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by