Hello. I want to do the following… Input: two sparse matrices A,B. Output: sparse matrix C, with C(i,j)=1 exactly when the ith column of A is equal to the jth column of B. The quickest code I have so far is this one:
r=[]; c=[]; for i=1:size(A,2) for j=1:size(B,2) if isequal(A(:,i),B(:,j)) r=[r,i]; c=[c,j]; end endendC=sparse(r,c,ones(1,length(r)));
But for big matrices it gets very slow. Is there a way to make it run faster?
cheers
Best Answer