LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Compare Array in LABView

Solved!
Go to solution

I'm a new member. Please help me compare two array.

EX:

Array1          Array2              ArrayResult

1.2                 1.2                    

4.3                 4.3       

5.6                 6.4                        6.4

7.1                 1.7                        1.7

4.3                 4.3        

Thanks for help

0 Kudos
Message 1 of 11
(1,688 Views)

Hi kienle,

 

what have you tried?

Where are you stuck?

 

What are your comparison conditions?


@kienle99 wrote:

EX:

Array1          Array2              ArrayResult

1.2                 1.2                    

4.3                 4.3       

5.6                 6.4                        6.4

7.1                 1.7                        1.7

4.3                 4.3        


Can you descibe in words how to compare and how to determine the ArrayResult?

Does the ArrayResult contain 5 elements or just 2 elements?

 

Do you know the difficulties of comparing floating point values?

"4.3" might not be the same as "4.3" once you display more significant digits!

Best regards,
GerdW


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

Hi GredW,

I want ArrayResult contain 2 elements.

 

I don't know the difficulties of comparing floating point value.

I just want to pick values of array2 different values of array1 in database. Is that hard?

 

Please help me, Thank you.

 

0 Kudos
Message 3 of 11
(1,638 Views)

Did you consider the Not Equals function?

0 Kudos
Message 4 of 11
(1,633 Views)

Hi RavensFan

 

Suddenly, but it repeat value of array1image.png

0 Kudos
Message 5 of 11
(1,630 Views)

Well, you used greater than or equal to, not   "not equal" to.

 

And if you turned on  the conditional tunnel for the auto-indexing array going out, then the boolean will decide which values get put into the exiting array, and which get left out.

 

You won't even need the case structure inside!

 

I would recommend you learn more about LabVIEW from here. How to Learn LV

0 Kudos
Message 6 of 11
(1,626 Views)
Solution
Accepted by topic author kienle99

comp.png

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 7 of 11
(1,616 Views)

@kienle99 wrote:

I just want to pick values of array2 different values of array1 in database. Is that hard?


The secret of getting the right answer is to ask the right question. So far the problem is ambiguous!

 

  • Do you want to compare the elements pairwise in element order and find the indices where they differ and return the element of array2? (This is easy and solutions are already provided). This also assumes that both arrays have the same number of elements.
  • Do you want to find all elements in array2 that don't exist anywhere in array1? (This is easy too, but requires quite different code. Here the input array sizes can be different). Since you talk about "database", this seems the more likely problem, but then it does not explain why some elements in array1 occur more than once.

(Also note that it is LabVIEW, not LABView. Using the wrong lettercase typically identifies you as a beginner. 😉 It also helps if you tell us your LabVIEW version, because the solution to the second problem could use techniques (e.g. "Set") that are not available in older versions).

 

0 Kudos
Message 8 of 11
(1,603 Views)

Thank you, Henrik_Volkers

 

I done with the coding. Thank you so much

0 Kudos
Message 9 of 11
(1,570 Views)

Hi AltenBach

 

Yes. Thank you for the advice.

0 Kudos
Message 10 of 11
(1,565 Views)