matlab按某一列排序

Excel中有按某一列排序,同时扩展到其他列,Matlab中对应的有sortrows:

The MATLAB function sortrows(A,j) sorts the rows of the matrix a based on the entries of the j-th column. For example, enter the following in MATLAB:

A = [1 2 3

   3 0 9

  6 5 4]

B = sortrows(A,2)

C = sortrows(A,3)

You will receive the following output:

B = 3 0 9

  1 2 3

  6 5 4

C = 1 2 3

   6 5 4

   3 0 9

Note: By default, the command sortrows(A) (i.e., without the j parameter) sorts by the first column of A, decides ties by the second column, decides further ties by the third column, and so on. For a three-column matrix, sortrows(A) is equivalent to sortrows(A,[1 2 3]).


出处: http://kb.iu.edu/data/afrd.html

你可能感兴趣的:(function,command,default,following,receive)