LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

count the occurrence of numbers in a 2d array labview

Highlighted

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
(1,679 Views)
Highlighted

Hi dave,

 

try to understand this:

check.png

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 2 of 6
(1,671 Views)
Highlighted

a little array reshaping goes a long waySmiley Wink

Capture.PNG

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

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 LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 4 of 6
(1,650 Views)
Highlighted

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
(1,639 Views)
Highlighted

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
(1,624 Views)