10-07-2020 09:40 PM
Hi I need help. I need to count repeated elements in array. How to do that?
Please see attached file for sample output.
I hope someone will help me.
Thank you.
Solved! Go to Solution.
10-07-2020 11:39 PM
Search the forums, as this question as come up before.
Older solutions used variant attributes you search for and save the names as variants, if you find it , you add one to the property. If you don't, you add the attribute and set its property to one. At the end, you read out all that you have. (I might have the exact terminology of the variants, attributes, and properties messed up, but when you find that thread, you'll see examples on how to implement.
Newer versions of LabVIEW have sets and maps that let you do something similar.
If you want, you can do it with straight arrays. You have the array you are searching and the array you are building. Search for each element in array 1 in array 2 (which starts out empty). If you find the element, then add 1 to the same index in array 3 which is the count of instances for the elements in array 2.. If you don't, you Build the element to the end of the array 2 and build an element of value 1 to the end of array 3.
10-08-2020 12:27 AM - edited 10-08-2020 12:35 AM
You have a 1D array of names, not a 2D array.
A slightly harder problem is described here, bnt once the words are turned into array elements, it's the same.
Ravens correctly stated that now we should do it using a map. If you look at slides 36/37 of my 2019 NI week presentation, you'll get the idea. What is your LabVIEW version?
See how far you get!
10-08-2020 01:06 AM - edited 10-08-2020 01:07 AM
Thank you very much for your help 🙂
10-08-2020 01:07 AM
Thank you very much for you help 🙂