HOW CAN I SORTED MY MATRIX DESCEND
1 次查看(过去 30 天)
显示 更早的评论
I HAVE A MATRIX M=[ 1 2 3 4 5 ;1 20 54 6 40] I WANT TO SORT MY MATRIX WITHIN THE SECOND COLON WITH ASCENDING WAY TO OBTEIND THIS RESULT :
M=[3 5 2 4 1;54 40 20 6 1]
HOW CAN I DO
0 个评论
采纳的回答
Andrei Bobrov
2015-11-22
编辑:Andrei Bobrov
2015-11-22
M=[ 1 2 3 4 5 ;1 20 54 6 40];
[~,ii] = sort(M(2,:),'descend');
out = M(:,ii);
or
out = sortrows(M',-2)';
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!