09-09-2015 10:17 PM
Hi everyone, I am trying to count how many numbers are duplicated in a 1D array. I just want to count different numbers. For example, I have this array:
1
2
1
3
1
2
4
The counter should be 2, because only the number one and two are duplicated, it does not matter how many times these numbers are duplicated.
Any help please?
PD: Sorry for my English, I speak spanish.
Solved! Go to Solution.
09-09-2015 10:31 PM
What have you tried? Start with sorting the array!
Are all numbers small posiive integers?
09-09-2015 11:20 PM
Hiiii
This will works
09-10-2015 07:22 AM
Attached is a simplified version that uses OpenG. Probably not as efficient, but easier to code, and easier to understand.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
09-10-2015 05:39 PM
Hi TWRLK!
Just as an FYI, NI has spanish speaking engineers (Like me!) so you can also post in spanish and get an answer from us. The code provided by karthickkece seems to do the trick :D! However, your chances of getting an answer from the community are way higher if you post your question in english as you did here.
Spanish version:
¡Hola! solo por si no sabias, NI también tiene ingenieros que hablan español (¡Como yo!) así que si formulas tu pregunta en español también puedes recibir asistencia de nuestra parte. El código que karthickkece parece hacer lo que vos describes. Igualmente, la mayoría de nuestros usuarios hablan ingles, por lo que es mucho más probable que puedas recibir colaboración de personas en la comunidad si creas tu post en inglés.
WenR
09-10-2015 06:42 PM
Than you very much. That is exactly what I needed.!!
09-10-2015 07:41 PM
Hi TWRLK,
Could I do in this way? Since I'm a little lazy to write the for loop.....
09-10-2015 09:17 PM
William1225 wrote:Could I do in this way? Since I'm a little lazy to write the for loop.....
Not if fractional values are allowed.
09-11-2015 10:41 AM - edited 09-11-2015 10:44 AM
If the input array only contains "relatively small" (i.e. <1e6) non-negative integers, here's a very efficient way to do all this.