how can i sort columns of a matrix in ascending order using loops without using the functions max,min,sort?
2 次查看(过去 30 天)
显示 更早的评论
I have a 15x10 matrix with numbers and i need to sort each column in ascending order
0 个评论
采纳的回答
Jonathon Gibson
2018-7-1
Here's a really simple, inefficient way:
M = rand(15,10)
for col = 1:size(M,2)
for iters = 1:size(M,1)
for row = 1:(size(M,1)-1)
if (M(row,col) > M(row+1,col))
temp = M(row,col);
M(row,col) = M(row+1,col);
M(row+1,col) = temp;
end
end
end
end
M
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!