필터 지우기
필터 지우기

How to delete duplicate row? unique is not working?

조회 수: 1 (최근 30일)
Ahmed Hamed
Ahmed Hamed 2016년 8월 3일
댓글: Stephen23 2016년 8월 4일
I have a matrix (in the attachment) that contains duplicated rows. I issued this command
spMBL = unique(spMBL, 'rows');
However, this doesn't delete the duplicated row
Any suggestions
  댓글 수: 1
Stephen23
Stephen23 2016년 8월 4일
Ever row is different:
>> all(any(diff(sortrows(spMBL),1,1),2))
ans = 1
and so unique gives the correct output.

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

채택된 답변

Bekay.Kang
Bekay.Kang 2016년 8월 4일
편집: Walter Roberson 2016년 8월 4일
% here's code!
[~,idx]=unique(spBML,'rows')
spBML_new=spBML(sort(idx),:)
:)

추가 답변 (1개)

Walter Roberson
Walter Roberson 2016년 8월 4일
spMBL = unique(spMBL, 'rows');
does work. The result has every row different than every other row. In the rows I examined, in each case row spMBL(J,:) is different than spMBL(J+1,:) in position size(spMBL,2)-J+1 . For example, size(spMBL,2) is 312, and spMBL(88,:) is different from spMBL(89,:) in position #312-88+1 = 225, so spMBL(88,225) is not equal to spMBL(89,225)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by