About unique command problem
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I used unique(A,'rows') to find unique rows of matrix A, however, it has a problem that after picking unique rows, it will order them in a manner. That is bad to my problem, I want to keep the order as originally in A.
Is there a command that prohibits sorting rows but only deleting same rows(reserve the first appearance) in MATLAB?
Thanks
0 个评论
采纳的回答
per isakson
2013-4-3
Doc says:
[C,ia,ic] = unique(A,setOrder) and [C,ia,ic] = unique(A,'rows',setOrder) returns
C in a specific order. setOrder='sorted' returns the values (or rows) of C in
sorted order. setOrder='stable' returns the values (or rows) of C in the same
order as A.
Try
setOrder='stable'
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Special Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!