Mapping 2 vectors – help to vectorize
Oh! One other option: since you’re looking for close correspondences between two sorted lists, you could go through them both simultaneously, using a merge-like algorithm. This should be O(max(length(xm), length(xn)))-ish. match_for_xn = zeros(length(xn), 1); last_M = 1; for N = 1:length(xn) % search through M until we find a match. for M = last_M:length(xm) dist_to_curr … Read more