In Matlab, how can I sort all of the rows of a matrix according to one of the columns?
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:
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 9Note: Inputting sortrows(A,1) returns the
same result as inputting sortrows(A).
For more about statistical and mathematical software, email the UITS Stat/Math Center, visit the center's web page, or phone 812-855-4724 (IUB) or 317-278-4740 (IUPUI). The center is located in Bloomington at 410 N. Park Avenue, and is open for consultation by appointment Monday-Friday 9am-5pm.
Last modified on February 03, 2011.







