This repository has been archived on 2021-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
NC/mp4/Project_4_Maggioni_Claudio/src/similarityfunc.m
Claudio Maggioni (maggicl) 34b290c569 mp4: done 1a-c in MATLAB
2020-11-04 14:59:14 +01:00

19 lines
No EOL
454 B
Matlab

function [S] = similarityfunc(Pts, sigma)
% Create the similarity matrix S from the coordinate list of the input
% points
% dimosthenis.pasadakis@usi.ch
% ICS, USI.
if nargin < 2
% Choose \sigma ~ 2*log(n)
n = length(Pts(:,1));
sigma = log(n);
end
fprintf('----------------------------\n');
fprintf('Gaussian similarity function\n');
fprintf('----------------------------\n');
S = squareform(pdist(Pts));
S = exp(-S.^2 ./ (2*sigma^2));
end