02-23-2024 10:36 AM
I have a 1d array containing 1,2,3,4,5,6 numbers which are repeated n no of times .i want to count no of occurances of each element in labview using search 1d array palette .
02-23-2024 11:27 AM
This kind of sounds like a homework assignment that you're posting and hoping we'll solve for you.
Have you even tried? If you post something that looks like you tried (screenshot, VI file, even a description of what you tried) but failed we may help point you in the right direction. We're fine with helping you actually learn.
If you just want someone to do your homework for you, this isn't the place for that.
02-23-2024 11:28 AM - edited 02-23-2024 02:26 PM
@qwaefxbnhhjugyjv wrote:
I have a 1d array containing 1,2,3,4,5,6 numbers which are repeated n no of times .i want to count no of occurances of each element in labview using search 1d array palette .
You should not tell us what to use (e.g. "search 1D array") because there are probably much better tools. I would probably use a map in the general case. (Maybe the bottom of slide #37 here can give you some ideas.).
However, if these are really all small positive integers, all you need is an array of counts where the index is the value. Keep it in a shift register and iterate over your input in a FOR loop.
02-23-2024 12:07 PM
Perhaps a histogram function would serve you.
02-23-2024 02:26 PM
@altenbach wrote:
However, if these are really all small positive integers, all you need is an array of counts where the index is the value. Keep it in a shift register and iterate over your input in a FOR loop.
See if you can reproduce this...
02-23-2024 05:51 PM
@altenbach wrote:
@altenbach wrote:
However, if these are really all small positive integers, all you need is an array of counts where the index is the value. Keep it in a shift register and iterate over your input in a FOR loop.See if you can reproduce this...
Or this:
02-23-2024 11:29 PM - edited 02-24-2024 10:21 AM
@paul_cardinale wrote:
Or this:
Did you actually run this and look at the x-values of the histogram???? (Hint: they are not integers!)
With some of playing, you can get it to work using the General Histogram.
(Histograms are for floating point values, and are not the right tool for discrete small non-negative integer stuff. And if the values are a collection of gigantic integers over the full range of potential values, we would use a map as mentioned already!)
02-24-2024 10:13 AM
@altenbach wrote:
@paul_cardinale wrote:
Or this:
Did you actually run this and look at the x-values of the histogram???? (Hint: they are not integers!)
That surprised me. Thanks for the edification.
02-24-2024 10:38 AM
I have never in my life found any use for the built-in histograms and always roll my own. They are ancient and clumsy. Why would we need all these redundant outputs if we can just unbundle the xy graph data to get the others?
Many times I define my bins according to the requirements, then increment the two closest bins proportionally to the fractional position between the bins. This guarantees that the median of the distribution is retained exactly, even for coarse bins.
For example if the value is exactly in the middle, I increment that bin, but if the value is right at the border between two bins, I fill two adjacent bins equally. Any other scenario proportionally. Here are three examples of what's added as a function of value (red arrow).
02-24-2024 12:03 PM
@altenbach wrote:
I have never in my life found any use for the built-in histograms and always roll my own. They are ancient and clumsy. Why would we need all these redundant outputs if we can just unbundle the xy graph data to get the others?
Many times I define my bins according to the requirements, then increment the two closest bins proportionally to the fractional position between the bins. This guarantees that the median of the distribution is retained exactly, even for coarse bins.
For example if the value is exactly in the middle, I increment that bin, but if the value is right at the border between two bins, I fill two adjacent bins equally. Any other scenario proportionally. Here are three examples of what's added as a function of value (red arrow).
Have you thought of rolling a generalized one?