-
Notifications
You must be signed in to change notification settings - Fork 1
/
find_distance_matrix.m
52 lines (39 loc) · 1.13 KB
/
find_distance_matrix.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function D = find_distance_matrix(vocalizations,parameters)
%finds distance matrix for an N x d matrix of vocalizations using dynamic
%time warping
%
% (C) Gordon J. Berman, 2016
% Emory University
if nargin < 2
parameters = [];
end
parameters = setRunParameters(parameters);
dtw_window = parameters.dtw_window;
N = length(vocalizations(:,1));
cellData = iscell(vocalizations);
D = zeros(N);
for i=1:N
if mod(i,100) == 0
fprintf(1,'Data Point #%5i out of %5i\n',i,N);
end
temp = zeros(1,N);
if ~cellData
a = vocalizations(i,:);
else
a = vocalizations{i};
end
parfor j=(i+1):N
if ~cellData
b = vocalizations(j,:);
else
b = vocalizations{j};
end
if ~isempty(dtw_window)
temp(j) = dtw_c(a,b,dtw_window);
else
temp(j) = dtw_c(a,b);
end
end
D(i,i+1:N) = temp(i+1:N);
D(i+1:N,i) = temp(i+1:N);
end