function idx = findIdx(roi,range) idx = max(find(range<=roi(1)))+1:max(find(range<=roi(2))); end