-
Notifications
You must be signed in to change notification settings - Fork 0
/
indexsearch.m
50 lines (40 loc) · 1.02 KB
/
indexsearch.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
function index=indexsearch(evs)
% find a simplex structure in the data
%
% index=indexsearch(evs)
%
% Input:
% evs: (N,k)-matrix with eigenvectors columnwise
%
% Output:
% index: k-vector with indices of objects that build the simplex vertices
%
% written by Marcus Weber, Zuse Institute Berlin, Takustrasse 7, 14195 Berlin
maxdist=0.0;
[N,k]=size(evs);
OrthoSys=evs;
index=zeros(1,k);
% first vertex: row with largest norm
for l=1:N
dist = norm(OrthoSys(l,:));
if (dist > maxdist)
maxdist=dist;
index(1)=l;
end
end
OrthoSys=OrthoSys-ones(N,1)*evs(index(1),:);
% all further vertices as rows with maximum distance to existing subspace
for j=2:k
maxdist=0.0;
temp=OrthoSys(index(j-1),:);
for l=1:N
sclprod=OrthoSys(l,:)*temp';
OrthoSys(l,:)=OrthoSys(l,:)-sclprod*temp;
distt=norm(OrthoSys(l,:));
if distt > maxdist %&& ~ismember(l,index(1:j-1))
maxdist=distt;
index(j)=l;
end
end
OrthoSys = OrthoSys/maxdist;
end