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.
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.
12-22-2014 04:04 PM - edited 12-22-2014 04:07 PM
Hello,
can someone show me how to do a max and min of an 2d array
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.
Solved! Go to Solution.
12-22-2014 04:11 PM
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.
12-22-2014 04:15 PM - edited 12-22-2014 04:17 PM
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.
12-22-2014 04:16 PM
12-22-2014 04:18 PM
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
12-22-2014 04:21 PM
@super_saiyans wrote:
yeah. it can
but i dont want to look at column 3,4,5
Use Array Subset to remove them.
12-22-2014 04:22 PM
i guess i can remove it, but i was hoping that there's another solution.
but okay. that will do for now. thanks!
12-22-2014 08:42 PM
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