Retrun largest numbers?

2 次查看(过去 30 天)
htet wai
htet wai 2018-5-10
评论: htet wai 2018-5-10
Can you help me how to retrun the larget numbers from the array as in the same order of that array?
for example i have A = 8 , 3, 4 , 1 , 5 , 6 , 2 , 7 , 9. I want to return largest 3 number in the same order as A like that B = 8 , 7 , 9.

采纳的回答

ES
ES 2018-5-10
编辑:ES 2018-5-10
>> [~, idx] = sort(A);
>> B = A(sort(idx(end-2:end))))

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Types 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by