From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

max and min of 2d array

Solved!
Go to solution

Hello,

can someone show me how to do a max and min of an 2d array

 

Untitled.png

 

i am oonly looking at colum 0,1,2

 

the max of 0,1,2

the min of 0,1,2

 

in my example, it would be 13.612 is max and min is 10.059

i am thinking i have to do two for loop but i havent figured out how. 

thanks in advance. 

0 Kudos
Message 1 of 8
(4,667 Views)

A single loop containing the Max/Min function would suffice.  Auto-indexing the 2-d array will give you rows and you are interested in columns.  So either transpose the array or use the Array Index function to get columns.  Wire the 1D array to Max/Min function, connecting the outputs to a shift register.  For each additional column, compare the new max/min values with those from the previous iteration and pass the correct value into the shift register.  Essentially comparing the max/min for each column to eachother in order to get the max/min for the whole array.  You can stop the loop early if you are only interested in a few columns.

0 Kudos
Message 2 of 8
(4,661 Views)

The Array Max & Min function can take in a 2D array.  No loop required.

Nevermind.  Just looked over your example again.  You will want to use Array Subset in order to get your first three columns and then use Array Max & Min.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 8
(4,654 Views)

The Array Max & Min function from the Array palette accept a 2D array input, just use it directly no need of any loop.

 

Ben64

Message 4 of 8
(4,651 Views)

yeah. it can

but i dont want to look at column 3,4,5

 

when i use it

i will see 13.612 as max

and 3.018 has min. which i am not interested in.

i am only looking between column 0,1,2

 

 

0 Kudos
Message 5 of 8
(4,647 Views)
Solution
Accepted by topic author super_saiyans

@super_saiyans wrote:

yeah. it can

but i dont want to look at column 3,4,5


Use Array Subset to remove them.

GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 8
(4,643 Views)

i guess i can remove it, but i was hoping that there's another solution.

but okay. that will do for now. thanks!

 

0 Kudos
Message 7 of 8
(4,640 Views)

You can keep your original data and only use the subset as an input to the max/min.  This only "removes" the extra data for your calculation while keeping the whole data set

Message 8 of 8
(4,584 Views)