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!

 채택된 답변

Ameer Hamza
Ameer Hamza 2020년 11월 23일

0 개 추천

댓글 수: 3

EBur
EBur 2020년 11월 23일
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!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

질문:

2020년 11월 23일

댓글:

2020년 11월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by