Finding 4 closest values to a value in an array
13 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Sindar
il 28 Set 2020
use mink
[~,idx] = mink(abs(data-find_point),5);
data(idx)
2 Commenti
Sindar
il 29 Set 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
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Shifting and Sorting Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!