Find repeated close values in array
Mostrar comentarios más antiguos
hello,
I have an array like
{86558,29952,29809,29804,29750,29749,29556,29382,29379,28474,15093,14974,14234,14136}
and my threshold is 3000 for checking their closeness to each other. I want to categorize them for example ~86k appears 1, ~29k appears 9, ~14k appears 3 times. I need this result like avg(~29k numbers) and their repetition time. How I can do this? I couldn't figure out. thanks.
Respuesta aceptada
Más respuestas (1)
Image Analyst
el 3 de Dic. de 2017
You can use pdist2() to find the "distance" of every element to every other element, if you have the Statistics and Machine Learning Toolbox:
v = [86558,29952,29809,29804,29750,29749,29556,29382,29379,28474,15093,14974,14234,14136]
distances = pdist2(v', v')
closeDistances = distances < 3000 % A logical matrix of whether they're close or not.
Categorías
Más información sobre Shifting and Sorting Matrices en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!