I have a n by d matrix A, representing n d-dimensional points. I have another m by d matrix B, representing m d-dimensional points.
- I wonder how to efficiently computer a m by n matrix, whose (i,j) element represents the Euclidean distance between the i-th row of matrix A and the j-th row of matrix B?
- How shall I efficiently determine a vector of m elements, whose k-th element represents the row of A closest to the k-th row of B?
Note I know how to do the above two using loops. But in Matlab, it is not efficient to use loops, so I ask these questions.
Thanks!