Finding 4 closest values to a value in an array
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
How do I find multiple points close to a particular number in an array? I can do this for one value but how do I extend that?
0 commentaires
Réponse acceptée
Sindar
le 28 Sep 2020
use mink
[~,idx] = mink(abs(data-find_point),5);
data(idx)
2 commentaires
Sindar
le 29 Sep 2020
You'd play around with (data-find_point) without the abs(). Algorithm something like:
- separate data into values equal to, larger than, smaller than find_point
- keep all equal to
- find smallest 2 positive error
- find largest 2 negative error
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!