【发布时间】:2014-02-14 12:23:33
【问题描述】:
在数据集中,如何对数据进行从大到小的排序?
使用sort数据由小变大:
a=[1 3 5 2 6];
b=sort(a);
b=[1 2 3 5 6];
但我想要b:
b=[6 5 3 2 1]
【问题讨论】:
在数据集中,如何对数据进行从大到小的排序?
使用sort数据由小变大:
a=[1 3 5 2 6];
b=sort(a);
b=[1 2 3 5 6];
但我想要b:
b=[6 5 3 2 1]
【问题讨论】:
检查http://www.mathworks.com/help/matlab/ref/sort.html。 sort 函数可以采用模式参数。
b = sort(a) % 'ascend' by default
b = sort(a, 'descend') % sort data from large to small
【讨论】:
【讨论】: