Nearest value from an array.
2 次查看(过去 30 天)
显示 更早的评论
I have a set of numbers 'N'.I need to find each optimal nearest value of each N , from a series.
If M=[1,2,3,4,5,6,7,8,910] a series.
N=[0.5,1.3,2.4] .I need find the optimal nearest point of each N from M.
采纳的回答
Andrei Bobrov
2019-9-20
M=[1,2,3,4,5,6,7,8,910]
N=[0.5,1.3,2.4]
[~,ii] = min(abs(M(:) - N(:)'));
out = M(unique(ii));
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Optimization Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!