how to select the second maximum value for an array.

답변 (2개)

Lucademicus
Lucademicus 2020년 1월 7일
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.

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

질문:

2020년 1월 7일

댓글:

2020년 1월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by