how to select the second maximum value for an array.

Antworten (2)

Lucademicus
Lucademicus am 7 Jan. 2020
One way would be to sort the array and take the value of the second to last value.
[a,b] = sort(A);
maximum = A(b(end-1));
There are multiple ways to achieve this. I'm sure somebody will come up with a nicer oneliner, but this should do your job.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 7 Jan. 2020

Kommentiert:

am 7 Jan. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by