Programming Previous page   Next Page

Sorting the Data in Each Row

Sort each row of A in descending order. Note that issorted tests for an ascending sequence. You can flip the vector to test for a sorted descending sequence:

When you specify a second output, sort returns the indices of the original matrix A positioned in the order they appear in the output matrix. In the following example, the second row of index contains the sequence 4 3 2 5 1, which means that the sorted elements in output matrix r were taken from A(2,4), A(2,3), A(2,2), A(2,5), and A(2,1):

Previous page  Sorting the Data in Each Column Sorting Row Vectors Next page

© 1994-2005 The MathWorks, Inc.