Rearrange matix in ascending order using one column as index!

2 ビュー (過去 30 日間)
Panos Ale
Panos Ale 2017 年 10 月 16 日
回答済み: KSSV 2017 年 10 月 16 日
Hallo! I have one matix with two columns where each value of column 1 correnponds to the value of the same row at column 2. I want to rearrange the matrix placing the items in column 1 in ascending order with its paired value of colymn 2.
example if i have a=[7 100;1 200;5 24,8;3 72] I want b=[1 200;3 72;5 24,8;7 100];

採用された回答

KSSV
KSSV 2017 年 10 月 16 日
a=[7 100;1 200;5 248;3 72]
b=[1 200;3 72;5 248;7 100] ;
[val,idx] = sort(a(:,1)) ;
b = a(idx,:)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSignal Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by