Finding the indexes of values of one vector to another Matlab

4 ビュー (過去 30 日間)
Teoman Selcuk
Teoman Selcuk 2021 年 12 月 3 日
編集済み: Dave B 2021 年 12 月 3 日
How woudl I be able to compute the following problem below? Where it gives the order of where sorted a is in a. I want to ahieve the expected Output below.
a = [13.8487, 20.8059, 23.5011, 23.2286, 22.2261];
sorted_a = sort(a);
comparison = find(a == sorted(a));
Expected Output
1 2 5 4 3

回答 (1 件)

Dave B
Dave B 2021 年 12 月 3 日
編集済み: Dave B 2021 年 12 月 3 日
What you described here is the second output of sort:
a = [13.8487, 20.8059, 23.5011, 23.2286, 22.2261];
[sorted_a,comparison] = sort(a)
sorted_a = 1×5
13.8487 20.8059 22.2261 23.2286 23.5011
comparison = 1×5
1 2 5 4 3

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by