LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to avoid Repeated value in a array

Hii


 i am having one array  which has nos as  1,2,3,4,2,3,4,5,1, etc
 
 Now i want to get only the no which apperad only once like 1,2,3,4,5
0 Kudos
Message 1 of 9
(3,737 Views)

Try this..

In the false case just pass the array as it is..

Hope this helps...

 

0 Kudos
Message 2 of 9
(3,727 Views)
Karthikey,
 
Here is a VI that I use to remove duplicate values from a 1D array of doubles.  It first sorts the array to avoid doing O(n^2) operations unnecessarily, so the output array will be sorted even if the input array isn't.  Since this takes an array of floating point values, I use a tolerance value to compare values.  If two values are within this tolerance, they will be considered duplicates.
 
I believe there is also a VI in the OpenG library that also removes duplicates, but I've noticed that it can be slow when working with very large arrays.
 
-Chris M
Message 3 of 9
(3,721 Views)
Smiley Very Happy I guess My solution is simpler Smiley Wink
0 Kudos
Message 4 of 9
(3,713 Views)
Hi Vsh,

your solution is simpler, but involves an "Is equal?" operation (in the search array node)!

And you should never compare floats for equality... That's why there is a tolerance in the other example! (Found via wikipedia)
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 9
(3,691 Views)

I Accept.

Thanks for the Info.Smiley Happy

0 Kudos
Message 6 of 9
(3,672 Views)

See Tomi's Community Nugget in the following link

http://forums.ni.com/ni/board/message?board.id=170&message.id=234871&jump=true

-Kumar.B

Message 7 of 9
(3,635 Views)
Hii

Now i am having one problem
How to search a string in a cluster array???
Provide an idea?
0 Kudos
Message 8 of 9
(3,627 Views)
you can use the for loop again. Connect the cluster array to For loop with auto indexing enabled. unbundle the cluster inside the for loop, check if the iput string is equal to the string in the cluster. If true, build the ith count in a case structure. Use a shift register for the same. The output of shift register  will contain the indices of the cluster array where the search string is matched.

Hope this helps.
0 Kudos
Message 9 of 9
(3,605 Views)