sorting vector by value and position

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 日

1 投票

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

1 件のコメント

Tomas
Tomas 2022 年 11 月 5 日
Thank you so much.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeShifting and Sorting Matrices についてさらに検索

タグ

質問済み:

2022 年 11 月 5 日

コメント済み:

2022 年 11 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by