-
Notifications
You must be signed in to change notification settings - Fork 0
/
interppolygon.m
executable file
·46 lines (36 loc) · 1.05 KB
/
interppolygon.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
function varargout = interppolygon(X,N,method)
[pl bl] = polygonlength(X);
orig_metric = [ 0 ; cumsum(bl/pl) ];
%X(idx,:)=[];
% 2. Interpolate
interp_metric = ( 0 : 1/(N-1) : 1)';
Y = interp1( ...
orig_metric,...
X,...
interp_metric,...
method);
% 3. Ouputs
varargout{1} = Y;
if nargout > 1
varargout{2} = orig_metric;
end
function varargout = polygonlength(X)
n_dim = size(X,2);
delta_X = 0;
for dim = 1 : n_dim
delta_X = delta_X + ...
diff(X(:,dim)).^2 ;
end
branch_lengths = sqrt( delta_X );
% if n_dim>=6
% idx = find(delta_X<3);
% branch_lengths(idx,:)=[];
% else
% idx = find(delta_X>=0);
% end
pl = sum( branch_lengths );
varargout{1} = pl;
varargout{2} = branch_lengths;
%varargout{3} = idx;
end
end