sort函数默认升序排列,即‘ascend’;
[B, index] = sort(A,dim, model)
B为排序后矩阵
index记录排序前的索引号
A需要进行排序操作的矩阵
dim对矩阵的维度(一维不用指定,二维默认对列)
model排序的模式,升序‘ascend’;‘descend’(默认‘ascend’)
>> [B, index] = sort(a, 'descend')
B =
65 23 7 4 3 1
index =
3 4 6 2 1 5