LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

To delete a non repeated element from Array.

Solved!
Go to solution

Hi...,

 

I have a 1D array of elements, I need to delete non repeated elements from that array and also need to print repeated elements only once.

 

Thankyou.

0 Kudos
Message 1 of 18
(1,463 Views)

Hi Hemanth,

 


@stark8 wrote:

I have a 1D array of elements, I need to delete non repeated elements from that array and also need to print repeated elements only once.


Sounds like typical homework…

 

What have you tried?

Where are you stuck?

Mind to provide your VI with typical input data?

 

You might rephrase your requirement:

"I need to output those elements from an 1D array that occur atleast twice."

Best regards,
GerdW


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

 

Hemanth8_0-1704705221421.png

This the array

0 Kudos
Message 4 of 18
(1,445 Views)

Hi Hemanth,

 

and what have your tried so far?

Is the input array always sorted?

 

Suggestion:

  1. Sort the array.
  2. Test, if the first elements is the same as the second.
  3. If unequal then keep that element in the (conditional) output tunnel.
  4. I equal continue the test with the next element(s) until you encounter another value…
Best regards,
GerdW


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

Here's the VI what i have tried.

0 Kudos
Message 6 of 18
(1,429 Views)

Hi Hermanth,

 

please downconvert the VI for LV2019… (File->Save for previous)

Best regards,
GerdW


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

Hi Hemanth,

Another method would be use InsertIntoSet option in a Loop based on the Size of the Array.

 

Concatenate the Input Element whenever the already Included output array from the InsertIntoSet Function is True.

 

In this case you will miss one element for each unique Array element for example for the input "Test1,Test2,Test2,Test3,Test3,Test3,Test4,Test4,Test4,Test4" You will get "Test2,Test3,Test3,Test4,Test4,Test4" as output you will need to append and short the array after the result.

 

This method will help you to understand how to use Set Function which you may not use frequently.

----------------------------------------------------------------------------------------------------------------
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.
-----------------------------------------------------------------------------------------------------------------
Message 8 of 18
(1,387 Views)
0 Kudos
Message 9 of 18
(1,375 Views)

Hi Hermanth,

 

why do you need so much code? (590kB vs 16kB)

(Just a suggestion, you can make this even simpler…)

Best regards,
GerdW


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