LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to find out and locate the top 100 max elements from a 4D array

I try to find out the 100 maximum elements in a 4D array and then I want to put the result in a 2D array, Which should show me the locations of the elements and the values of those elements
====================
=Labview 7.0 & 8.0 & 8.5=
=====================
0 Kudos
Message 1 of 3
(2,864 Views)
Hi,

Don't know why you want a 2D array, this VI puts the results in a bundle.
Just because it seems more practical to me (there's less room for
mistakes)...

The VI works as follows:
The max value is returned, incl. it's index.
Then it is replaced by the original minimum value, minus one.
If the last found maximum is the (original) minimum, everything is skipped.

If you really want a 2D array, instead of a bundle, replace the contant with
an empty 2d array, the bundle with a build array, and the indicator with a
2d array...

Regards,

Wiebe.

"asd iyvjh" wrote in message
news:50650000000800000017AC0000-1066448259000@exchange.ni.com...
> I try to find out the 100 maximum elements in a 4D array and then I
> want to put the result in a 2D ar
ray, Which should show me the
> locations of the elements and the values of those elements



[Attachment Max 100 Values From 4D Array.vi, see below]
0 Kudos
Message 2 of 3
(2,864 Views)
> I try to find out the 100 maximum elements in a 4D array and then I
> want to put the result in a 2D array, Which should show me the
> locations of the elements and the values of those elements

The easiest and most efficient will probably be to Reshape the 4D array
into a 1D array. Find the hundred largest elements in the 1D array,
then use the dimsizes to compute the 4D indices from the 1D index.

To find the maxes of a 1D array, you can either use Array Max/Min
repeatedly, and substitute -inf or something after each find, or you can
add the index number to a cluster with the original amplitude, then sort
and take the first one hundred elements -- the index tells you where
they came from in the array.

Too map back 1D to 4D, a 2x3x4x5 array has
120 elements (0-119) in 1D
form. Given a 1D index X, to turn it into a 4D index a, b, c, d, you
first divide X by 5, put the remainder in d, then divide the quotient by
4 and put the remainder in c, ... and place the final remainder in a.

Greg McKaskle
0 Kudos
Message 3 of 3
(2,864 Views)