How to sort a matrix by using values in another vector in matlab?
问题 My situation is: I get a 1000*2 matrix and a 1000*1 vector. And the row i in the matrix is mapped to the element i in the vector. And the elements in the vector are all integer. Now I want to sort the elements in the vector from low to high. And I want to get a new matrix with the sequence of the new vector. And the mapping relationships are equal to the original situation. How to do this in Matlab? Thanks! 回答1: Use sortrows: First concat your vector to your matrix: M2 = [V, M]; Then sort