sort command
2 次查看(过去 30 天)
显示 更早的评论
hi, if i have this array. x=[1 2; 6 8; 1 10;3 2;3 6 ;6 1]; if I sort the first column , can the other columns is arranged according to sorting of first column? as below: 1 2 1 10 3 2 3 6 6 8 6 1
thanks
0 个评论
回答(2 个)
Jan
2011-11-18
x = [1 2; 6 8; 1 10; 3 2; 3 6; 6 1];
[x1, index] = sort(x(:, 1));
Xsorted = x(index, :); % or [x1, x(index, 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!