How to locate number from a matrix

1 次查看(过去 30 天)
I have matrix list2, it's a 526x2 double. Suppose the first column represents the ID of people, and the second column represents the total amount of films they shot. I want to find out the N most prolific films shot by the people. I used sort(list2(:,2),'descend') to rearrange the second colomn to get the most movie shot to the least. However, I also need to determine the people's ID, so the question is how to relocate back to the person's ID if we have the information of the second column?

采纳的回答

KSSV
KSSV 2021-11-30
If idx is the indices of the locations in second column...to get the respective first column just use:
iwant = list2(idx,1)
  5 个评论
Kaijia Chen
Kaijia Chen 2021-11-30
So I rearrange the second column because I wanna find the people in descending order. The problem is how to relocate the first column in the same order? Thank you!
KSSV
KSSV 2021-11-30
A = rand(10,2) ;
[val,idx] = sort(A(:,2)) ;
iwant = A(idx,1)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Denoising and Compression 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by