-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathnhood.m
55 lines (44 loc) · 991 Bytes
/
nhood.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
53
54
55
% nhood : Neighborhood selection
%
%
% TMH/2005
%
function [inhood,order_list]=nhood(pos_known,pos_est,options);
if ~isfield(options,'max')
options.max=Inf;
end
if isinf(options.max)
inhood=1:size(pos_known,1);
order_list=inhood;
return
end
nknown=size(pos_known,1);
ndim=size(pos_known,2);
usemax=min(options.max,nknown);
if (nknown<=usemax)
inhood=[1:1:nknown];
order_list=[1:1:nknown];
return
end
method=2;
if isfield(options,'d2u');
method=1;
end
if method==2;
% CALCULATE DISTANCE
% COMPUTATIONAL EXPENSIVE
d=zeros(nknown,1);
for ir=1:nknown
d(ir)=edist(pos_est,pos_known(ir,:));
end
id=[1:nknown]';
order_list=sortrows([id,d],[2]);
order_list=order_list(:,1);
else
d=options.d2u;
id=[1:nknown]';
order_list=sortrows([id,d],[2]);
order_list=flipud(order_list(:,1));
end
% SELECT NEIGHBORHOOD
inhood=order_list(1:usemax);