Finding 4 closest values to a value in an array
12 ビュー (過去 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 で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!