Obtain the sorted index vector
31 次查看(过去 30 天)
显示 更早的评论
Suppose a vector with element. in Matlab, I can use the following code to sort the vector in descending order as follow:
y=sort(x,'descend'), for example, x=[0.5; 0.4; 0.6; 0.9], then y=[0.9; 0.6; 0.5; 0.4].
I need to Obtain the sorted index vector. Here it will be z=[4; 3; 1; 2]
I need to find z for any arbitrary sorted vector.
0 个评论
采纳的回答
Bruno Luong
2022-3-4
编辑:Bruno Luong
2022-3-4
Use the second output of sort
x=[0.5; 0.4; 0.6; 0.9]
[y,z] = sort(x,'descend')
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!