[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Newbie - Common value patterns in many vectors
From: |
Fernando |
Subject: |
Re: Newbie - Common value patterns in many vectors |
Date: |
Wed, 5 Oct 2011 23:06:38 -0700 (PDT) |
Hi there
I have a possible solution but it also needs to pad the matrix with zeros
Here is a possible solution using ismember function
[r,c] = size(matrix) ;
k = 1:r;
out = [] ; M = zeros(r,r);
for i = 1:r
rowvec = nonzeros( matrix(i,:) );
for ii = 1:r
X = nonzeros( matrix(ii,:) );
[a,b] = ismember( rowvec , X );
out = [out sum(a) ];
end
M(i,:) = out;
out = [];
end
M =
4 2 3 3 0
2 6 2 4 0
3 2 10 4 2
3 4 4 6 0
0 0 2 0 3
Not the fastest way to do it but it will work. Here M gives you the total
matches.
--
View this message in context:
http://octave.1599824.n4.nabble.com/Newbie-Common-value-patterns-in-many-vectors-tp3874114p3877164.html
Sent from the Octave - General mailing list archive at Nabble.com.