function N = mk_matching_matrix_N(lab1,lab2) % MK_MATCHING_MATRIX_N - Returns the matching matrix corresponding to two partitions % % Written by: % -- % John L. Weatherwax 2009-03-17 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- % Get some of the preliminary information. ulab1 = unique(lab1); ulab2 = unique(lab2); n1 = length(ulab1); n2 = length(ulab2); n = length(lab1); % Now find the matching matrix N N = zeros(n1,n2); I = 0; for i = ulab1(:)' I = I + 1; J = 0; for j = ulab2(:)' J = J + 1; indI = find(lab1 == i); indJ = find(lab2 == j); N(I,J) = length(intersect(indI,indJ)); end end