# LabVIEW

cancel
Showing results for
Did you mean:

## finding the 25th largest number in an array

How would I say find the 25th largest number in an array?

Or nth largest number?

Chris
Message 1 of 13
(2,049 Views)

## Re: finding the 25th largest number in an array

n-th max value of an array...
Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010, 2014

LVVILIB.blogspot.com
Message 2 of 13
(2,049 Views)

## Re: finding the 25th largest number in an array

Hi Chris,

The attached V7.0 vi should do the trick.

Hope this helps,

Nick
Message 3 of 13
(2,049 Views)

## Re: finding the 25th largest number in an array

Hi Chris,

Sorry forgot to reverse array for Max value.

Nick
Message 4 of 13
(2,049 Views)

## Re: finding the 25th largest number in an array

Hello

You have got good answers. Now, I want to point one thing: should you have to eliminate duplicate values prior to calculate th nth value, take a look in www.openg.org. their toolkit has a vi to do that.

Hope it helps.

Alipio
---------------------------------------------------------
"Qod natura non dat, Salmantica non praestat"
---------------------------------------------------------
Message 5 of 13
(2,049 Views)

## Re: finding the 25th largest number in an array

hi,

Jus wanna to say that our example vi is of improvsed (I did it in 5 minutes as soon as I saw the posting), thus not able to provide best solution.

Please bear in mind that spoon-feed won't help. We are jus doing our best to help.

Thanks.
Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010, 2014

LVVILIB.blogspot.com
Message 6 of 13
(2,049 Views)

## Re: finding the 25th largest number in an array

Ok. I know everybody tries to help doing his best.
I only wanted to show a good source of labview code. I think OpenG people works hard and they will feel happy if can be of help for labview community.

Thanks.
---------------------------------------------------------
"Qod natura non dat, Salmantica non praestat"
---------------------------------------------------------
Message 7 of 13
(2,049 Views)

## Re: finding the 25th largest number in an array

I find most of these answers correct, but without previous knowledge of the size of the array, I would do things differently.

In the enclosed VI, a cluster is formed of all array values and their index. When the array is then sorted, the first cluster element is used as the first sort criterium, then the second cluster element. This allows a single array operation (Sorting) to take care of any searching, whilst the cluster retains the index of the original array.

Coupling this method with an unitialised shift register, you can also cache the sorted array to allow for more rapid processing if you require more than a single indexed value.

Another way to achieve this is (Assuming you`re seeking the 25 largest) to simply get the max and min at t
he very beginning, feed the array into a loop with a shift register, set the value at the index returned for max each run to the initial min value -1, and repeat another 24 times.

Regarding memory use and execution speed, I`m not sure if searching an array 25 times is quicker than a single sort or not (No new array is created), but both versions are viable.

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Message 8 of 13
(2,049 Views)

## Re: finding the 25th largest number in an array

Good evening!

Nuttin' to it, my friend. Look at the attached vi.

Eric
Eric P. Nichols
P.O. Box 56235
North Pole, AK 99705
Message 9 of 13
(2,049 Views)

## Re: finding the 25th largest number in an array

🙂
Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010, 2014

LVVILIB.blogspot.com
Message 10 of 13
(2,049 Views)