Azzera filtri
Azzera filtri

Retrun largest numbers?

2 visualizzazioni (ultimi 30 giorni)
htet wai
htet wai il 10 Mag 2018
Commentato: htet wai il 10 Mag 2018
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.

Risposta accettata

ES
ES il 10 Mag 2018
Modificato: ES il 10 Mag 2018
>> [~, idx] = sort(A);
>> B = A(sort(idx(end-2:end))))

Più risposte (0)

Categorie

Scopri di più su Data Types in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by