1 | function [box zero range eigvec]=make_box4(points)
|
---|
2 | %OK
|
---|
3 | N=size(points,1);
|
---|
4 | dim=size(points,2);
|
---|
5 | num_of_points=round(N^(1/dim));
|
---|
6 |
|
---|
7 | meanval=mean(points,1);
|
---|
8 | [eigvec,eigval]=eig((points-ones(N,1)*meanval)'*(points-ones(N,1)*meanval));
|
---|
9 | range=2*sqrt(diag(eigval)/N);
|
---|
10 |
|
---|
11 | box=zeros(N,dim);
|
---|
12 | pointer=-range;
|
---|
13 | step=2*range/(num_of_points-1);
|
---|
14 | jump=[1 num_of_points num_of_points^2];
|
---|
15 | %plot3(points(:,1), points(:,2), points(:,3),'r.' ); hold on
|
---|
16 | for i=1:N
|
---|
17 | for k=1:dim
|
---|
18 | box(i,k)=pointer(k)+step(k)*mod(floor((i-1)/jump(k)),num_of_points);
|
---|
19 | end
|
---|
20 | %plot3(box(:,1), box(:,2), box(:,3),'b.' )
|
---|
21 | end
|
---|
22 |
|
---|
23 | box=(box)*eigvec'+ones(N,1)*meanval;
|
---|
24 | range=ones(dim,1)./(2*range);
|
---|
25 | zero=box(1,:);
|
---|
26 | %plot3(box(:,1), box(:,2), box(:,3),'b.' );
|
---|
27 | plot(box(:,1), box(:,2),'b.' ); hold on
|
---|
28 | plot(points(:,1), points(:,2), 'r.' ); hold off
|
---|
29 |
|
---|
30 | end
|
---|