how to find K nearest neighbors?
2 views (last 30 days)
Show older comments
Hi guys,
I have a sparse matrix and I need to find the 10 nearest neighbors between each row and the rest rows of the matrix. I used this command: [idx, D] =knnsearch(B,A,'distance','cosine','K',10); but the problem is that no matter which value I choose for K, it finds only one nearest neighbor! can anyone have any idea?
Thank you, Aram
1 Comment
Cedric
on 26 Apr 2013
Edited: Cedric
on 26 Apr 2013
What does "between each row and the rest of the matrix" mean? You have e.g. row 400 and you want to get the 10 elements whose row indices are closest to 400 whatever their columns are? If so, does it include elements on row 400? Or is it about values? E.g. 10 closes values to row 400 average/median?
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!