Sorting two simple matrices

1 次查看(过去 30 天)
Hi! I need to sort matrix A from least to greatest; however, the values are tied to matrix B. How can I can make B adjust with a matrix A sort.
Matrix A and B are the starting values, and A' and B' are the desired answer.
A = [ 2, 3, 1, 4]
B = [ 6, 5, 1, 10]
A' = [ 1, 2 , 3, 4]
B' = [ 1, 6, 5, 10]

采纳的回答

James Tursa
James Tursa 2021-2-23
编辑:James Tursa 2021-2-23
Use the 2nd output argument of the sort( ) function, which has the indexing. E.g.,
[Asorted,ix] = sort(A);
Bsorted = B(ix);

更多回答(0 个)

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by