How can I sort vector according to its index?

2 次查看(过去 30 天)
Hello every body
I have a problem,
I would like to sort vector
vect that contain
vect = [3 1 3 4]
each value in the vector vect has its index like
ind =[ 1 2 3 4]
so, I want sort the vector vect in descending order with keeping its index correctely
like that
vect =[ 4 3 3 1]
ind = [ 4 1 3 2]
How Can I do that, please help me!
Thank you.

回答(1 个)

Matt J
Matt J 2021-9-13
[vect,ind]=sort(vect,'descend')

类别

Help CenterFile Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息

标签

产品


版本

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by