find the 3 maximum elements and their index
3 次查看(过去 30 天)
显示 更早的评论
hi everyone, i have a vector and i need to find the 3 maximum elements and their index, plz can anyone help me in that? thx
0 个评论
采纳的回答
更多回答(1 个)
Jonathan Sullivan
2012-2-29
r = rand(100,1);
[val ind] = sort(r,'descend');
val(1:3)
ind(1:3)
r(ind(1:3))
2 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!