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!

 Respuesta aceptada

Ameer Hamza
Ameer Hamza el 23 de Nov. de 2020

0 votos

3 comentarios

EBur
EBur el 23 de Nov. de 2020
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!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Preguntada:

el 23 de Nov. de 2020

Comentada:

el 23 de Nov. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by