MATLAB: Sorting in descending order by row

sortsorting

hi, i have a square matrix and i need to sort it in descending order in each row, i mean from left to right along columns for each row. all the functions like sort and sortrow are in ascending order or sort in descending order by column ! thank you

Best Answer

Where M is your matrix:
>> M = randi(9,4)
M =
6 1 9 5
5 1 8 8
6 4 9 9
6 3 3 4
>> -sort(-M.').'
ans =
9 6 5 1
8 8 5 1
9 9 6 4
6 4 3 3