How to delete duplicate row? unique is not working?
1 次查看(过去 30 天)
显示 更早的评论
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
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
2016-8-4
编辑:Walter Roberson
2016-8-4
% here's code!
[~,idx]=unique(spBML,'rows')
spBML_new=spBML(sort(idx),:)
:)
0 个评论
更多回答(1 个)
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)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!