sorting vector by value and position

1 次查看(过去 30 天)
Hello, i need to sort this vector by value and also keep the position [109 97 116 108 97 98] to [5 1 6 4 2 3].
Any ideas how to do it?

采纳的回答

Torsten
Torsten 2022-11-5
A = [109 97 116 108 97 98];
[~,p] = sort(A,'ascend');
r = 1:length(A);
r(p) = r
r = 1×6
5 1 6 4 2 3

更多回答(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