I need to solve a minimization problem with Matlab and I\'m wondering which is the easiest solution. All the potential solutions that I\'ve been thinking in require lot of p
Let Lat
and Long
denote latitude and longitude matrices, then
dist2=sum(bsxfun(@minus, cat(3,A,B), cat(3,Lat,Long)).^2,3);
[I,J]=find(dist2==min(dist2(:)));
I
and J
contain the indices in A
and B
that correspond to nearest point. Note that if there are multiple answers, I
and J
will not be scalar values, but vectors.