Sorting columns of a matrix without sort()

I have a 15x10 matrix with random generated integers between 0 and 100. I have to sort the columns in ascending order using a bubble sort algorithm. I am not supposed to use sort(). I have no clue how to even start.
Thank you everbody for your help!

 Accepted Answer

3 Comments

Thanks, but I understand how to use bubblesort for rows but I don't understand how to transfer it to sorting columns of a matrix
Once you have done it for a row, you can just use a for loop.
M; % matrix
for i = 1:size(M,2)
col = M(:,i);
% apply sorting algorithm on col
M(:,i) = col;
end
Thank you! That helped me finding the answer!

Sign in to comment.

More Answers (0)

Categories

Asked:

on 23 Nov 2020

Commented:

on 23 Nov 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!