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 日

0 投票

>> [~, idx] = sort(A);
>> B = A(sort(idx(end-2:end))))

1 件のコメント

htet wai
htet wai 2018 年 5 月 10 日
Thank you for your help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Type Conversion についてさらに検索

タグ

質問済み:

2018 年 5 月 10 日

コメント済み:

2018 年 5 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by