How to get the max value index and the next max value index and next until the end (the smallest) of the array
2 ビュー (過去 30 日間)
古いコメントを表示
For example if A Vector
A=[5.2,6.3,1.2,10,2,4.3];
I want to get the index of the max value (in my example is 10 so the index is 4) then find the next max value which is 6.3 then the index is 2,,, the final output i need it to be as follows:
I=[3,2,6,1,5,4]
where I the returned indices corresponding to A
0 件のコメント
採用された回答
その他の回答 (1 件)
madhan ravi
2019 年 1 月 6 日
[~,I]=sort(A)
3 件のコメント
madhan ravi
2019 年 1 月 6 日
編集済み: madhan ravi
2019 年 1 月 6 日
"[D,I] = sort(A) also returns a sort index I which specifies how the
elements of A were rearranged to obtain the sorted output D:"
>> [D,I]=sort(A)
D =
1.2000 2.0000 4.3000 5.2000 6.3000 10.0000
I =
3 5 6 1 2 4 % indices of orginal values
>>
参考
カテゴリ
Help Center および File Exchange で Operators and Elementary Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!