LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

count the occurrence of numbers in a 2d array labview

i have a attached a Vi with a 2d array of integers. What im struggling to do is to count the occurence of numbers in the array and then then histogram this. For example if there were 10 occurences of the number 16 then the histogram will show 16 along the X axis and 10 on the Y axis.

 

i need to do this for every number on the array and plot the reuslts on one single array.

 

Any help would be great. i have looked on some of the examples but they are all dealing wioth 1d arrays.

 

Dave

0 Kudos
Message 1 of 6
(3,420 Views)

Hi dave,

 

try to understand this:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(3,412 Views)

a little array reshaping goes a long waySmiley Wink

Capture.PNG


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 6
(3,393 Views)

Hi Jeff,

 

I'm aware of ReshapeArray, but my approach demonstrates the basic LabVIEW elements of autoindexing arrays and shift register usage. That's the main point I want to teach the OP! 😉

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 6
(3,391 Views)

No trouble at all Gerd.  I figured you had a reason to avoid the built-in function.


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 6
(3,380 Views)

Just to throw in another solution (specific to this problem; modifications needed if bin size changes). I like this trick of counting the number of elements equal to a number in an array. It may not be most efficient, but it's clean and I use it quite often so it's a good one to know.

 

0 Kudos
Message 6 of 6
(3,365 Views)