function [indexWithSelf] = mostRepVector(simMatrix) % Determines the most representative element in a set C1 % Inputs: % 1. simMatrix: n*n matrix of pairwise similarities % simMatrix(i,j) = similarity between points c_i and c_j (both in the % same class) % Outputs: % 1. indexWithSelf: index of the most representative element, with self % similarities % 2. indexWithoutSelf: index of the most representative element, without % self similarities. indexWithSelf = 0; n = size(simMatrix, 1); simWithDiags = zeros(n,1); for i= 1:n for j=1:n simWithDiags(i) = simWithDiags(i) + simMatrix(i,j); simWithoutDiags(i) = simWithDiags(i); end end [what, where] = max(simWithDiags); indexWithSelf = where;