Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ramy-badr-ahmed/kd-tree-matlab
KD-Tree Implementation in MATLAB - https://doi.org/10.5281/zenodo.12808902
https://github.com/ramy-badr-ahmed/kd-tree-matlab
binary-space-partitioning data-structures-and-algorithms hypercube-points kd-tree matlab nearest-neighbor-search space-partitioning spatial-indexing
Last synced: 11 days ago
JSON representation
KD-Tree Implementation in MATLAB - https://doi.org/10.5281/zenodo.12808902
- Host: GitHub
- URL: https://github.com/ramy-badr-ahmed/kd-tree-matlab
- Owner: Ramy-Badr-Ahmed
- License: apache-2.0
- Created: 2024-07-15T21:44:56.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-08-12T09:35:47.000Z (4 months ago)
- Last Synced: 2024-10-25T04:24:25.790Z (about 2 months ago)
- Topics: binary-space-partitioning, data-structures-and-algorithms, hypercube-points, kd-tree, matlab, nearest-neighbor-search, space-partitioning, spatial-indexing
- Language: MATLAB
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![MATLAB](https://img.shields.io/badge/MATLAB-%23D00000.svg?style=plastic&logo=mathworks&logoColor=white) ![GitHub](https://img.shields.io/github/license/Ramy-Badr-Ahmed/KD-Tree-Matlab?style=plastic)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.12808902.svg)](https://doi.org/10.5281/zenodo.12808902)
# KD-Tree Implementation in MATLAB
This repository contains MATLAB scripts for implementing and using a kd-tree data structure and implements k-nearest neighbour search.
The kd-tree is a space-partitioning data structure for organising points in a k-dimensional space.
### About
> [Mathematica Link](https://reference.wolfram.com/language/ref/datastructure/KDTree.html)
### Scripts
1. `buildKDTree.m`
> Builds a kd-tree from a set of points.
2. `nearestNeighborSearch.m`
> Performs nearest neighbour search using the built kd-tree.
3. `hypercubePoints.m`
> Showcases an application to generate n-Dimensional Points Uniformly in an n-Dimensional Hypercube.
### Example Usage
```matlab
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);
```