如何去除矩阵重复行 [英] How to remove duplicate rows from matrix
问题描述
我想从矩阵removw duplcate行。
I want to removw duplcate rows from matrix.
注意:我读<一个href=\"http://stackoverflow.com/questions/3065387/how-can-i-remove-duplicates-in-an-array-but-keep-the-same-order\">How我可以删除重复的数组,但保持相同的订单,但是这不是我想要的东西;
Note: I read How can I remove duplicates in an array but keep the same order?, but this is not exactly what I want;
解决方案上面,从矩阵删除重复值(细胞)(返回向量),但我需要删除重复的 ROWS 并同时返回矩阵 - 同样的矩阵,而不重复的行
The solution above removes duplicate values(cells) from matrix(and returns vector), but I need to remove duplicate ROWS and return also matrix - the same matrix without duplicate rows.
例如:
a = [1,2; 3,4; 5,6; 1,2; 7,8]
a =
1 2
3 4
5 6
1 2
7 8
%...
ans =
1 2
3 4
5 6
7 8
的顺序并不重要。
The order doesn't matter.
推荐答案
请参阅http://www.mathworks.com/help/techdoc/ref/unique.html
B =唯一的(A,行)返回的唯一行。
b = unique(A, 'rows') returns the unique rows of A.
这篇关于如何去除矩阵重复行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!