Given the same matrix m = [1 2 3; 2 1 5; 4 6 4; 2 3 2], create matrix n with rows sorted in a descending order of elements in the second column.
Given the same matrix m = [1 2 3; 2 1 5; 4 6 4; 2 3 2], create matrix n with rows sorted in a descending order of elements in the second column.
Solution:
m = [1 2 3; 2 1 5; 4 6 4; 2 3 2] [n, index] = sortrows(m,2, 'descend');
Comments
Post a Comment