MATLAB Answers

Link closest points accross altitudes in Matlab, problem with Delaunay Triangulation/ Nearest neighbor finding

2 views (last 30 days)
Paul C
Paul C on 10 Nov 2014
Edited: Paul C on 10 Nov 2014
I have a 3d matrix with scattered points (Nx4 matrix, x-y-z-data). My aim is to link the closest points together and register each chain in an Kx4 array (x, y, z, data), K being the chain length. The total number of chains depends on the points... A particularity is that these lines only go upwards (z+), I don't want to link points on same z, or go down.
I have been trying different strategies so far, one being with another array shape (Mx4xNz - basically meaning the values were stacked per z's instead of being all on a 2d matrix):
1. pick a point at level Zn
2. go to level Zn+1, look for the closest point in a range of coordinates x,y using delaunayTriangulation and nearestNeighbor
3. register the point into a vector
(I suspect there are other possibilities using nearestNeighbor with the Nx4 matrix, but i can't think how to 'direct' the search upwards and chain the successive points... )
I find myself with the following problem : The finding of nearest point upwards seems to work well but in 1 horizontal direction only!!
<> (linking that doesn't work)
Anyone has an idea as to why this is happens? I suspect the problem might be with assigning correctly the nearest neighbor found, but I don't see how the extraction I did in my code below would be wrong?? Thanks for any help!!
Note - During the loop I have the warning : Duplicate data points have been detected and removed. The Triangulation indices are defined with respect to the unique set of points in delaunayTriangulation property X.
for i = 1:s;
for n=1:max_iter-1;
Wn=W(:,:,n); % W is the data 3d-matrix Mx4xNz, as attached
Point_n = Wn(pp_id,:);
xn= Point_n(1);
yn= Point_n(2);
zn= Point_n(3);
vn= Point_n(4);
if xn==0|yn==0|zn==0|vn==0;
% Look for nearest neighbour at next level
[pp_id, d]=nearestNeighbor(DT,[xn,yn]);
% limit range
if d>10
% extraction of values at row pp_id
% register point in line
hold on;
for i=1:s

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!