function [index] = getMostRepElement(trainMat) % Given a database of elements, finds the most representative element % within the database % trainMat: m*n matrix (m elements each having dimension n) % Output: % 1. index: index of the most representative element numElements = size(trainMat, 1); simMatrix = zeros(numElements, numElements); %numFeatures = size(trainMat,2) -1; for i=1:numElements for j=1:numElements simMatrix(i,j) = getSimCounting(trainMat(i,:), trainMat(j,:)); end end [index] = mostRepVector(simMatrix);