function [myIndexMatrix,myDistMatrix] = calculateMyDistanceMatrix(myDataset)

n = size(myDataset,1);  % the instance size of the matrix
d = size(myDataset,2) - 1; % the feature size of the matrix excluding the effort

myDistMatrix = inf * ones(n,n); % define distance matrix as all infinities
myIndexMatrix = inf * ones(n,n); % define indice matrix

% calculate the distances
for i = 1:n
    for j = i:n
        tmpDist = sqrt(sum((myDataset(i,1:d) - myDataset(j,1:d)).^2));
        myDistMatrix(i,j) = tmpDist; % assign the distance to related cell
        myDistMatrix(j,i) = tmpDist; % assign distance to mirror image
    end
    tmpVector = myDistMatrix(i,:);
    [tmpSorted tmpIndices] = sort(tmpVector);
    for k = 1:n
       myIndexMatrix(i,tmpIndices(k)) = k; 
    end
end

% replace ones with a very big number
myIndexMatrix(find(myIndexMatrix==1)) = 999999999999;
myDistMatrix(find(myDistMatrix==0)) = 999999999999;
end