function [distance] = findDistance(levelElements,i,j) distance = 0; for k = 1:size(levelElements(i).features,1) distance = sqrt(sum( (levelElements(i).features(k)).^2 + (levelElements(j).features(1)).^2 )); for l = 2:size(levelElements(j).features,1) tempDist = distance + sqrt(sum( (levelElements(i).features(k)).^2 + (levelElements(j).features(l)).^2 ));clc % % min-dist approach % if tempDist < distance % distance = tempDist; % end % max-dist approach % if tempDist > distance % distance = tempDist; % end end end end