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

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 11월 8일
편집: Andrei Bobrov 2012년 11월 8일

1 개 추천

index = bsxfun(@plus,ind(:),-2:2);
OR full solution
index = bsxfun(@plus,min(abx(bsxfun(@minus,numdates(:),date_l(:).'))),(-2:2).');

추가 답변 (1개)

Rica
Rica 2012년 11월 8일

0 개 추천

that is really great. how do find in google something like this? i try it to find it myself before i asked the question...
thanks again

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

질문:

2012년 11월 8일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by