Programming Previous page   Next Page

Sorting the Data in Each Column

The sort function sorts matrix elements along a specified dimension. The syntax for the function is

To sort the columns of a matrix, specify 1 as the dimension argument. To sort along rows, specify dimension as 2.

This example first constructs a 3-by-5 matrix:

Sort each column of A in ascending order:


Previous page  Shifting the Location of Matrix Elements Sorting the Data in Each Row Next page

© 1994-2005 The MathWorks, Inc.