nearest neighbor orientation in matlab code example Example: find nearest neighbor matlab Idx = knnsearch(X,Y);