10-04-2019 12:08 AM
10-04-2019 12:20 AM - edited 10-04-2019 12:24 AM
Based on your code, I'm guessing you're trying to count each value in the array?
If you're using LabVIEW 2019, this is a perfect application for a Map.
If not, you can do the same using Variant Attributes.
You want some key (the value of the "array 2" element) and then a value (the number of times it appears).
You can get the value by adding one each time, as you are currently doing (although consider the use of In-Place Element Structure with Index/Replace Array Element if not changing to Var Attribs or Map, either of which will use the same In-Place Element Structure but with different nodes).
An example is below (is this what you're trying to do?)
Count occurrences of each value
10-04-2019 01:05 AM - edited 10-04-2019 01:08 AM
There's also the Unique Numbers and Multiplicity.vi, found in the Mathematics->Polynomial palette. It'll give you an array of all of the unique numbers from the input array, and an array of how many times each of those numbers appears in the input array.
Edit: Open up that VI and see how it works, and compare it to your own VI. Your approach looks pretty similar.
10-04-2019 01:11 AM - edited 10-04-2019 01:12 AM
@MichaelBalzer wrote:
There's also the Unique Numbers and Multiplicity.vi, found in the Mathematics->Polynomial palette.
I knew there'd be a built in version somewhere...
10-04-2019 02:38 AM
Let me see.... Hmmm. are you trying to find the MODE of the input array? Why, Yes you are!
10-04-2019 03:28 AM
@JÞB wrote:
Let me see.... Hmmm. are you trying to find the MODE of the input array? Why, Yes you are!
This is very straightforward, but it doesn't give the number of occurrences. Still not exactly sure what the OP wants, but good to have another tool in the toolbox!
01-28-2024 05:39 AM
Can you please share the link of this VI,it's exactly what i needed.
01-28-2024 04:09 PM
ceuca.ioana7@gmail.com wrote:
Can you please share the link of this VI,it's exactly what i needed.
All code above are actually LabVIEW snippets and already contain all code.
(personally, I would probably use a map instead. 😄 )
01-28-2024 04:25 PM - edited 01-28-2024 04:27 PM
@altenbach wrote:
(personally, I would probably use a map instead. 😄 )
For example as follows:
(this is not a snippet, so try to recreate it. Most is in the collection palette, requires LabVIEW 2019 or newer. Watch my presentation for details)
I intentionally made the values integer, because equal comparison with DBL are potentially problematic.