Local Neighborhood
Very short and simple function to take a data set and to filter out the values that don't fall into the local neighborhood (of a specified norm radius with a specified norm) of some specified reference point. I've often had the need to do this, and thought that it might be useful for some people, as a lot of important assumptions are local and cannot be applied to all the data available.
The file works as follows:
1) All the data points that fall outside the infinity norm of the reference point and norm size are immediately removed, as this is computationally cheap and can take out large parts of the region (points in all other norms are included in the infinity, so the good points are kept).
2) The norm is then calculated for the points that remain, and those that fall outside the local neighborhood are culled.
3) The remaining points are sorted based on distance away from the reference.
Results will vary with computer/data, but in general this shouldn't take more than a few seconds, provided that the data matrix is dense and something that MATLAB can store. It would probably take longer for very large sparse matrices.
Cite As
FDR (2024). Local Neighborhood (https://www.mathworks.com/matlabcentral/fileexchange/33846-local-neighborhood), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.