indexing of an array of index
1 次查看(过去 30 天)
显示 更早的评论
Hi!
% for l=1:length(date_l)
[~, ind(l)] = min(abs(numdates-(date_l(l))));
end
i get the array ind
How could i get the ind of the minimum and the two index before and the two after ?
what should i change here [~,ind(l)] to get the result?
Thank you
0 个评论
采纳的回答
Andrei Bobrov
2012-11-8
编辑:Andrei Bobrov
2012-11-8
index = bsxfun(@plus,ind(:),-2:2);
OR full solution
index = bsxfun(@plus,min(abx(bsxfun(@minus,numdates(:),date_l(:).'))),(-2:2).');
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!