注册 登录
编程论坛 Matlab

找出相同的行的函数!

zsyrose 发布于 2006-09-21 10:54, 1027 次点击
请问如何在一个矩阵中将所有相同的行找出来!有没有现成得函数呢?
4 回复
#2
zsyrose2006-09-23 11:47

Now, I can give a solution.
for matrix A=[1 2; 2 3; 1 2], the following function can be used to find the same row in the matrix A.

function result=find_same_row(A)

[rowA,colA]=size(A);
B=unique(A,'rows');
[rowB,colB]=size(B);
for i=1:rowB
temp=B(i,:);
result=find((min((A==temp(ones(1,rowA),:)),[],2))');
end

#3
danger8882006-09-23 16:41

歧义太大,没说清要干什么啊

#4
zsyrose2006-09-23 19:41

For example, A=[1 2 ;2 3; 1 2; 1 2].
How can i find the rows which have the same elelments in A? Is it clear this time?

#5
hitzhang2006-09-24 17:39
请用命令   unique
1