Sort every single row
4 次查看(过去 30 天)
显示 更早的评论
How can I sort every single row of a matrix in ascending order? For example [16 2 3 13; 5 11 10 8] becomes [2 3 13 16;5 8 10 11] Thanks for help!
0 个评论
采纳的回答
per isakson
2015-2-18
One way
M = [16 2 3 13; 5 11 10 8] ;
for rr = 1 : size( M, 1 )
M( rr, : ) = sort( M( rr , : ), 'ascend' );
end
更多回答(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!