number of nearest neighbous around each element of a matrix
Ältere Kommentare anzeigen
I have a matrix that contain coordinates I=[x y z]. I need to find the number of nearest neighbors for each point in the matrix within a radius R. Thanks a lot!
Jack,
Akzeptierte Antwort
Weitere Antworten (1)
Youssef Khmou
am 18 Mai 2014
Bearbeitet: Youssef Khmou
am 18 Mai 2014
This problem can be solved using the equation of radius in three dimensional space such as if x²+y²+z² < R² then the point is inside the sphere, let us elaborate an example :
M=randn(300,3);
R=0.5;
for n=1:300
if sqrt((M(n,1)^2)+(M(n,2)^2)+(M(n,3)^2))<= R
C(n,:)=M(n,:);
end
end
1 Kommentar
jack
am 19 Mai 2014
Kategorien
Mehr zu Statistics and Machine Learning Toolbox finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!