Finding 4 closest values to a value in an array
15 次查看(过去 30 天)
显示 更早的评论
采纳的回答
Sindar
2020-9-28
use mink
[~,idx] = mink(abs(data-find_point),5);
data(idx)
2 个评论
Sindar
2020-9-29
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!