This code can be used to find the distance between x locations (stored in vect1) and y locations (stored in vect2). I modified this from something I found online. Works pretty good and I like the out put, also optimal in terms of speed.
Using this to construct similarity ranks! win!
% for finding the distance between the sets of points and printing them out
% by labels!
b = zeros(length(vect1),2);
for i = 1: length(vect1)
b(i,1) = vect1(i);
b(i,2) = vect2(i);
end
k = 0;
for i = 1:length(b)
for j = 1:length(b)
if j~=i
k=k+1;
index(k,:) = [i j];
end;
end;
end;
dist = ((b(index(:,2),1)-b(index(:,1),1)).^2 + (b(index(:,2),2)-b(index(:,2),2)).^2).^0.5;
m = [index(:,1),index(:,2),dist];
No comments:
Post a Comment