Create example.m
This commit is contained in:
parent
9b838d3e2c
commit
5084b058ab
1 changed files with 17 additions and 0 deletions
17
Task/K-d-tree/Matlab/example.m
Normal file
17
Task/K-d-tree/Matlab/example.m
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
numPoints = 5000;
|
||||
cubeSize = 10;
|
||||
numDimensions = 10;
|
||||
|
||||
points = hypercubePoints(numPoints, cubeSize, numDimensions);
|
||||
|
||||
hypercubeKDTree = buildKDTree(points);
|
||||
|
||||
queryPoint = rand(1, numDimensions); % for the k-nearest neighbour search
|
||||
|
||||
[nearestPoint, nearestDist, nodesVisited] = nearestNeighbourSearch(hypercubeKDTree, queryPoint);
|
||||
|
||||
fprintf('Points in KD-Tree:\n');
|
||||
fprintf('Query point: (%.2f, %.2f, %.2f)\n', queryPoint);
|
||||
fprintf('Nearest point: (%.2f, %.2f, %.2f)\n', nearestPoint);
|
||||
fprintf('Distance: %.4f\n', nearestDist);
|
||||
fprintf('Nodes visited: %d\n', nodesVisited);
|
||||
Loading…
Add table
Add a link
Reference in a new issue