Sort a Matrix by the first column connecting the row elements so that the elements of the second column 'follow' those of the first.

1 次查看(过去 30 天)
Hello Guys, i have a two column Matrix, where the first column is the diameter of some particles and the second column is Extiction. So the elements of the second column correspond to those of the first. My question is, is there a function that lets me sort the first column in ascending or descending order (does not matter) so that the corresponding value of extiction 'follows'? thank you very much.

采纳的回答

KSSV
KSSV 2021-9-14
A = rand(10,2) ;
[val,idx] = sort(A(:,1)) ;
iwant = A(idx,:)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by