The purpose of (sort(mat'))'
in Matlab is to sort the rows of the matrix mat
in ascending order. Here's how it works:
mat'
transposes the matrix mat
, so the columns become rows and the rows become columns.sort(mat')
sorts the rows of mat'
in ascending order. Each row is treated as a separate entity and sorted independently.(sort(mat'))'
transposes the sorted matrix back to its original form. Now the rows are the same as before, but they are sorted in ascending order.Here's an example of how it works with a 3 by 4 unsorted matrix:
main.m238 chars16 lines
As you can see, the rows of mat
have been sorted in ascending order in sorted_mat
.
gistlibby LogSnag