How to sort a column of data based on another?
20 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Wolfgang McCormack
il 7 Feb 2021
Risposto: Cris LaPierre
il 7 Feb 2021
Hi everyone, I have two columns of data. I wan to sort column A in theascending order and I want the corresponding values in column B be sorted as well according to A. How to do this in MATLAB?
Thanks!
0 Commenti
Risposta accettata
Più risposte (1)
weikang zhao
il 7 Feb 2021
`[B,I] = sort(___) also returns a collection of index vectors for any of the previous syntaxes. I is the same size as A and describes the arrangement of the elements of A into B along the sorted dimension. For example, if A is a vector, then B = A(I).`
Record the index vector when sorting the array, then use the index vector to adjust another array.
0 Commenti
Vedere anche
Categorie
Scopri di più su Shifting and Sorting Matrices in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!