Finding the 3rd largest element in an array.
조회 수: 8 (최근 30일)
이전 댓글 표시
I've been thinking about sorting the array and extracting the 3rd element , or using max command while everytime i delete the data from a temporary array. But i'm wondering ... How do i find the 3rd largest element in an array using a loop/if or some sort of this stuff.
Thanks, Eran.
답변 (2개)
dpb
2017년 4월 9일
Just go with the first option; the latter sorts the array three separate times. Unless the array size is humongous should be "adequately fast enough".
There's no problem, E formatting is simply an output artifact; doubles are doubles in internal memory storage and everything numerical is a double by default in Matlab unless you specifically cast to some other storage class such as single or in32 or the like.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!