LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search 2D Array

Since you're looking for an array (row) in a 2D array the basic Search in 1D array wont really cut it. However, LV is clever enough to compare array with a normal = command. So by looping through the 2D array you can compare the row with the 1D ones following the same logic (-1 for not found, stop search on found) with the following:

22721i488A420D67F9CA38

or like this (at 2nd thought i like this better)

22723iD0717D5624051DEC

/Y

 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 11 of 15
(1,345 Views)

We're almost there.

 

For's solution can get rid of one boolean operation if the comparison is set to compare aggregates. Also the "select" needs to be done only once, and not with every iteration of the loop. (not sure if the compiler can recognize it as loop invariant code...probably not).

Yamaeda's solution above needs a FOR loop instead of a while loop, eliminating evaluation of the extra termination condition.

 

Here's what I would do:

 

Message 12 of 15
(1,334 Views)

To be fair, Yamaeda is using LV8.2.  But, for those of us "living in the now", the For loop is the way to roll.

Message 13 of 15
(1,328 Views)

Ah, OK. I did not read the signature... 😉

0 Kudos
Message 14 of 15
(1,325 Views)

Well I'm running 2010 at home for a while longer, didn't think about the aborting For.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 15 of 15
(1,279 Views)