2014-02-14 45 views
0

在數據集中,如何將數據從大到小排序? 使用sort數據成爲從小到大:將數據從大到小排序

a=[1 3 5 2 6]; 
b=sort(a); 
b=[1 2 3 5 6]; 

,但我想b

b=[6 5 3 2 1] 
+1

[點擊進入](http://stackoverflow.com/questions/5802512/sorting-arrays-in-matlab)[一](HTTP://計算器。 com/questions/18820130/sort-matlab-array-in-descending-order)[word](http://www.mathworks.se/help/matlab/ref/sort.html)[...](http: //matlabgeeks.com/tips-tutorials/sorting-data-in-matlab/) –

+0

'doc sort'會讓你在那裏。 – SamuelNLP

回答

4

Yuan's answer是要走的路。

一些稍微hackish的替代品:

b = -sort(-a); 
b = fliplr(sort(a));