LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Comparing an Element to a 2D Array

For my project, I'm trying to create either a case structure or a 2 event strutcture that will change based on the compared values. I want to see if a pair of coordinates (2 doubles/1D arrary) are found in a 2D array of thousands of other coordinates. Depending if they match, I'll have two different actions. What is the best way to go about this? 

0 Kudos
Message 1 of 5
(3,356 Views)

Hi Cake,

 

how are your data arranged?

I suspect your 2D array consists of 2 columns, one column for X and one for Y coordinate…

 

Search the first column for your X coordinate. If you found a hit you check the corresponding Y coordinates!

(Keep in mind comparing floats can be dangerous…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(3,340 Views)

(Keep in mind comparing floats can be dangerous…)



A little new to labview, but is comparing DBL's really bad I'm assuming? Should I change the values to INTs to avoid this issue?

0 Kudos
Message 3 of 5
(3,335 Views)

@CakeBoss14 wrote:

For my project, I'm trying to create either a case structure or a 2 event strutcture that will change based on the compared values. 


  • Event structures are for user interactions, not for data driven code. Use a case structure.
  • Instead of having a Nx2 2D array, you could operate on a complex 1D array.
  • As others have already said, comparisons of floating point numbers are tricky. Instead of "equal", you should find the values that are "close enough" based on the problem.

 

Can you show us some simple exampe code and data?

0 Kudos
Message 4 of 5
(3,326 Views)
Share us the code, which you tried...
If your data type needs to double then compare based on upper and lower limit other than equal....
If u don't have problem in converting to integer you can very well use integer for comparison
----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 5 of 5
(3,321 Views)