You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CalculateAffinity.m 488B

5 years ago
12345678910111213141516
  1. function [affinity] = CalculateAffinity(data)
  2. % set the parameters
  3. sigma = 1;
  4. data = full(data);
  5. affinity = zeros(size(data,1), size(data,2));
  6. for i=1:size(data,1)
  7. for j=i:size(data,2)
  8. dist = sqrt(norm(data(i,:) - data(j,:)));
  9. %dist = sqrt((data(i,1) - data(j,1))^2 + (data(i,2) - data(j,2))^2);
  10. affinity(i,j) = dist;
  11. affinity(j,i) = affinity(i,j);
  12. end
  13. end
  14. affinity = exp(-affinity./(2*sigma^2));
  15. affinity = sparse(affinity);