LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Split 2d array where the maximum value

Hello, everyone,

 

I have a 2D array that consists of a computation of two 1D arrays (Array1, Array2). Now I want to get the row from the 2D array at the position where the maximum value of array 1 is. is that possible? has anyone any idea how to get that? i made a simplified vi to show what i mean

 

basically i need to split the row of the 2d array, where the value of array 1 its maximum has.

 

I would be really thankful for any help!!

 

best regards

 

 

0 Kudos
Message 1 of 5
(1,504 Views)

Hi,

 

Just by doing what you are describing :

 

Find the max of 1D array and get the row value

With that row value extract data from the 2D array

sup.png

0 Kudos
Message 2 of 5
(1,471 Views)

What happens if there are more than one max?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 5
(1,463 Views)

billko_0-1654609678606.png

Something like that?

 

Edit:

LOL I'm late to the party.  But mine doesn't involve transposing.  😄

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 5
(1,449 Views)

Please explain your use of the term "split"? Do you want to just get one row? "split" typically means something else!

 

Some comments on your VI:

 

  • There is no need to use any local variables. It is also bad because you are changing the value of a control so the next time you run the VI, you get a different result. A shift register would be the correct thing.
  • There is no need to maximize the diagram and front panel to the screen. At your state of learning you should be able to look at both as well as having the help window open at the same time.
  • Unconditionally appending an element to an empty array is the same as autoindexing at the output boundary. No shift register needed. 
  • "Insert into array" is NOT the correct tool to append an element to an existing array. Use "built array" instead!
  • Not sure why your array is orange if you exclusively dealing with integers.
  • Since both 1D arrays have the same size, all you need is exactly one FOR loop.
  • If you would build the array inside the (single) FOR loop, you don't need to transpose.

 

Here's roughly equivalent code with the solution how the get the row containing the max of the first row.

 

altenbach_0-1654613184053.png

 

0 Kudos
Message 5 of 5
(1,437 Views)