Is there any way to code this on a different way?

I want to get the max value of a variable and the number #100(max). I got this code:
[b,index] = maxk(lat1,100);
b_new = b([1,100])
Is there any way to write it to get directly the #1 and #100?

2 Kommentare

I wonder if you want max(lat1, 100)
I want #1 and #100 and its indices

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Jan
Jan am 16 Feb. 2022

0 Stimmen

No. This is the efficient solution already. To get the 100.th most frequent element, you have to determine the frequencies of all other elements also.

Weitere Antworten (0)

Kategorien

Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 16 Feb. 2022

Kommentiert:

am 16 Feb. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by