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
Ameer Hamza
Ameer Hamza 2020 年 11 月 23 日
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
EBur
EBur 2020 年 11 月 23 日
Thank you! That helped me finding the answer!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeShifting 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