フィルターのクリア

sorting data in matrix

2 ビュー (過去 30 日間)
Kieran
Kieran 2013 年 10 月 18 日
編集済み: Andrei Bobrov 2013 年 10 月 18 日
say i have a matrix
a = [2 3; 1 3; 3 2; 2 2; 1 2; 3 1; 2 1; 1 1]
i would like to rearrange a such that the first column is sorted in ascending order corresponding to the number in the second column ie. this matrix should become
asorted = [1 3; 2 3; 1 2; 2 2; 3 2; 1 1; 2 1; 3 1]
how can this be done automatically

採用された回答

Andrei Bobrov
Andrei Bobrov 2013 年 10 月 18 日
編集済み: Andrei Bobrov 2013 年 10 月 18 日
asorted = sortrows(a,[-2 1])

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by