sorting 2D matrix with 2 rows monotonically rising

I have a 3 rows by 5000 columns matrix A. If I plot scatter3(A(1,:),A(2,:),A(3,:)), then all the data can be displayed monotonically increasing on each axis. Now, I tried to sort both first and 2nd row in monotonically increasing order at the same time. I tried Asort=sortrows(A', [1 2]), newA=Asort'. However, only the first row is monotonically increasing and the 2nd row is not.

回答 (1 件)

Image Analyst
Image Analyst 2015 年 5 月 27 日

0 投票

Well, then try being more explicit:
row1 = A(1, :);
sortedRow1 = sort(row1, 'ascend');
row2 = A(2, :);
sortedRow2 = sort(row2, 'ascend');
sortedA = [sortedRow1; sortedRow2; A(3, :)];

カテゴリ

ヘルプ センター および File ExchangeShifting and Sorting Matrices についてさらに検索

製品

質問済み:

2015 年 5 月 26 日

回答済み:

2015 年 5 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by